Merge branch 'local-setup' into release #20
This file contains hidden or 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 Frontend | |
| on: | |
| push: | |
| branches: | |
| - release | |
| env: | |
| FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 18 # safer than 20 for now | |
| - name: Install Dependencies | |
| run: yarn install --frozen-lockfile --ignore-engines | |
| working-directory: frontend | |
| - name: Create ENV file | |
| run: echo "${{ secrets.ENV_PRODUCTION }}" > .env.production | |
| working-directory: frontend | |
| - name: Build Frontend | |
| run: CI=false yarn build | |
| working-directory: frontend | |
| - name: Validate deploy secrets | |
| env: | |
| AWS_ACCESS_KEY_INPUT: ${{ secrets.AWS_ACCESS_KEY_ID || secrets.AWS_KEY }} | |
| AWS_SECRET_KEY_INPUT: ${{ secrets.AWS_SECRET_ACCESS_KEY || secrets.AWS_SECRET }} | |
| S3_BUCKET_INPUT: ${{ secrets.S3_BUCKET }} | |
| CF_DISTRIBUTION_ID_INPUT: ${{ secrets.CF_DISTRIBUTION_ID }} | |
| run: | | |
| test -n "$AWS_ACCESS_KEY_INPUT" || { echo "Missing AWS access key"; exit 1; } | |
| test -n "$AWS_SECRET_KEY_INPUT" || { echo "Missing AWS secret key"; exit 1; } | |
| test -n "$S3_BUCKET_INPUT" || { echo "Missing S3_BUCKET"; exit 1; } | |
| test -n "$CF_DISTRIBUTION_ID_INPUT" || { echo "Missing CF_DISTRIBUTION_ID"; exit 1; } | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID || secrets.AWS_KEY }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY || secrets.AWS_SECRET }} | |
| aws-region: ap-south-1 | |
| - name: Upload to S3 | |
| run: aws s3 sync frontend/build s3://${{ secrets.S3_BUCKET }} --delete | |
| - name: Invalidate CloudFront Cache | |
| run: | | |
| aws cloudfront create-invalidation \ | |
| --distribution-id ${{ secrets.CF_DISTRIBUTION_ID }} \ | |
| --paths "/*" |