Skip to content

Update Github Actions - build docker image and deploy to Github registry #40

Update Github Actions - build docker image and deploy to Github registry

Update Github Actions - build docker image and deploy to Github registry #40

Workflow file for this run

name: Deploy
# Run on pushes to main or PRs
# on:
# # Pull request hook without any config. Launches for every pull request
# pull_request:
# # Launches for pushes to main or dev
# push:
# branches:
# - develop
# # Launches build when release is published
# release:
# types: [published]
on: [push]
jobs:
initialize:
runs-on: ubuntu-latest
outputs:
cache_key: ${{ steps.get_cache_key.outputs.cache_key }}
steps:
- uses: actions/setup-node@v1
with:
node-version: 12
- uses: actions/checkout@v2
with:
submodules: true
- name: Set cache key
id: get_cache_key
run: |
git submodule status > submodule.status
echo "::set-output name=cache_key::cache-repo-${{ hashFiles('yarn.lock', 'package.json', 'submodule.status') }}"
- uses: actions/cache@v2
id: cache-repo
with:
path: |
**/node_modules
contracts/build
key: ${{ steps.get_cache_key.outputs.cache_key }}
- name: Install dependencies and compile contracts
if: ${{ !steps.cache-repo.outputs.cache-hit }}
run: |
yarn run initialize
- name: yarn run build:alm
run: yarn run build
- name: Configure AWS credentials for STG
if: github.ref == 'refs/heads/develop'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
# Step to deploy to the Staging environment
- name: 'Deploy to S3: Staging'
if: github.ref == 'refs/heads/develop'
run: aws s3 sync alm/build s3://${{ secrets.AWS_STAGING_BUCKET_NAME }} --delete
# # Script to upload release files
# - name: 'Upload release build files for production'
# if: startsWith(github.ref, 'refs/tags/v')
# run: aws s3 sync public s3://${{ secrets.AWS_STAGING_BUCKET_NAME }}/releases/${{ github.event.release.tag_name }} --delete
- name: Configure AWS credentials for PROD
if: github.ref == 'refs/heads/master'
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
# Step to deploy to the production environment
- name: 'Deploy to S3: PRODUCTION'
if: github.ref == 'refs/heads/master'
run: aws s3 sync alm/build s3://${{ secrets.AWS_PROD_BUCKET_NAME }} --delete