Deploy #192
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy | |
on: | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Which environment to deploy to [dev|prod].' | |
default: dev | |
required: true | |
jobs: | |
deploy_to_s3: | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
PUBLIC_URL: '' | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v2.4.1 | |
with: | |
node-version: 16 | |
- name: Print env | |
run: env | |
- name: Install dependencies | |
run: yarn | |
- name: Build | |
if: ${{ github.event.inputs.environment == 'dev' || !github.event.inputs.environment }} | |
run: yarn run build:dev | |
- name: Deploy to dev | |
if: ${{ github.event.inputs.environment == 'dev' || !github.event.inputs.environment }} | |
uses: reggionick/s3-deploy@v3 | |
with: | |
folder: build | |
bucket: airdrop.thechaindata.com | |
bucket-region: ap-southeast-2 | |
invalidation: /* | |
dist-id: ${{ secrets.CLOUDFRONT_ID_DEV }} | |
delete-removed: false | |
no-cache: true | |
private: true | |
- name: Build for production | |
if: github.event.inputs.environment == 'prod' | |
run: npm run build | |
- name: Deploy to prod | |
if: github.event.inputs.environment == 'prod' | |
uses: reggionick/s3-deploy@v3 | |
with: | |
folder: build | |
bucket: airdrop.subquery.foundation | |
bucket-region: ap-southeast-2 | |
invalidation: /* | |
dist-id: ${{ secrets.CLOUDFRONT_ID_PROD }} | |
delete-removed: false | |
no-cache: true | |
private: true | |
clean_cloudfront_cache: | |
runs-on: ubuntu-latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
steps: | |
- name: clean cache dev | |
if: ${{ github.event.inputs.environment == 'dev' || !github.event.inputs.environment }} | |
uses: chetan/invalidate-cloudfront-action@v2 | |
env: | |
DISTRIBUTION: ${{ secrets.CLOUDFRONT_ID_DEV }} | |
PATHS: '/*' | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'us-east-1' | |
- name: clean cache prod | |
if: ${{ github.event.inputs.environment == 'prod' || !github.event.inputs.environment }} | |
uses: chetan/invalidate-cloudfront-action@v2 | |
env: | |
DISTRIBUTION: ${{ secrets.CLOUDFRONT_ID_PROD }} | |
PATHS: '/*' | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: 'us-east-1' |