Add cloudfront distribution #450
Workflow file for this run
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: DeployFrontendServerlessDev | |
on: | |
push | |
jobs: | |
deploy-frontend-dev: | |
runs-on: ubuntu-latest | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2.3.3 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: "20" | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
role-to-assume: arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/github-actions-frontend-access | |
aws-region: ap-south-1 | |
- name: Build frontend and copy zip to S3 | |
run: | | |
cd nuxt-frontend | |
sed -i "s|VITE_RECAPTCHA_SITE_KEY_VALUE|${{ secrets.RECAPTCHA_SITE_KEY }}|g" config.js | |
sed -i "s|RESOURCES_URL|${{ secrets.RESOURCES_URL }}|g" config.js | |
sed -i "s|CLOUDFRONT_URL_VALUE|${{ secrets.CLOUDFRONT_URL_VALUE_DEV }}|g" config.js | |
sh ./../deploy/generate-sitemap.sh https://dev-stack.canopas.com https://dev-stack-api.canopas.com | |
yarn install --frozen-lockfile && yarn build | |
cd .output/server && zip canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip -r . && aws s3 cp canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip s3://canopas-lambda-handlers && cd ../.. | |
aws s3 sync --cache-control 'max-age=604800' --exclude *.html ./.output/public s3://canopas-website-ssr-dev | |
aws s3 sync ./.output/public s3://canopas-website-ssr-dev | |
aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID_DEV }} --paths "/sitemap.xml" | |
- name: Deploy cloudformation stack | |
id: canopas-website-dev-lambda-stack-frontend | |
uses: aws-actions/aws-cloudformation-github-deploy@v1 | |
with: | |
name: canopas-website-dev-lambda-stack-frontend | |
template: infrastructure/frontend.yml | |
capabilities: CAPABILITY_IAM,CAPABILITY_NAMED_IAM, CAPABILITY_AUTO_EXPAND | |
timeout-in-minutes: "10" | |
no-fail-on-empty-changeset: "1" | |
parameter-overrides: >- | |
EnvName=dev, | |
ZipFileName=canopas_website_SSR_dev_${{ github.sha }}-${{ github.run_attempt }}.zip |