Skip to content

Add workflows for tagging and building release for Production deploym… #2

Add workflows for tagging and building release for Production deploym…

Add workflows for tagging and building release for Production deploym… #2

Workflow file for this run

name: Automatic Deployment to Dev/Staging
on:
push:
branches: [master]
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
deploy:
name: Deployment
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./packages/app
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up node
uses: actions/setup-node@v2
with:
node-version: 16
- name: Cache yarn cache
uses: actions/cache@v2
with:
path: "**/node_modules"
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
- name: Install dependencies
run: |
yarn install
pip install awscli --upgrade --user
- name: Build website
run: yarn static
- name: Configure AWS Dev credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.DEV_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.DEV_AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
# Script to deploy to the dev environment
- name: 'Deploy to S3: Dev'
if: github.ref == 'refs/heads/master'
run: aws s3 sync out s3://${{ secrets.AWS_DEV_BUCKET_NAME }}/current --delete
- name: 'Cloudfront Production: cache invalidation'
if: (startsWith(github.event.ref, 'refs/tags/v') || github.event_name == 'release')
run: |
aws cloudfront create-invalidation --distribution-id ${{ secrets.DEV_AWS_CLOUDFRONT_ID }} --paths "/*"
- name: Get the version
id: get_version
run: echo ::set-output name=VERSION::$(echo $GITHUB_REF | cut -d / -f 3)
# Script to upload release files
- name: 'Upload release build files for staging'
if: github.event.action == 'published'
run: aws s3 sync out s3://${{ secrets.AWS_DEV_BUCKET_NAME }}/releases/${{ steps.get_version.outputs.VERSION }} --delete