Publish site to S3 #3
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: Publish site to S3 | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
env: | |
BUCKET_NAME: ${{ secrets.BUCKET_NAME }} | |
AWS_REGION: ${{ secrets.AWS_REGION }} | |
IAM_DEPLOYMENT_ROLE_ARN: ${{ secrets.IAM_DEPLOYMENT_ROLE_ARN }} | |
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} | |
permissions: | |
id-token: write | |
contents: read | |
jobs: | |
S3PackageUpload: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Git clone the repository | |
uses: actions/checkout@v4 | |
- name: configure aws credentials | |
uses: aws-actions/configure-aws-credentials@v3 | |
with: | |
role-to-assume: ${{ env.IAM_DEPLOYMENT_ROLE_ARN }} | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Build website | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 22 | |
- name: Install dependencies | |
run: yarn | |
- name: Build website | |
run: yarn build | |
- name: Copy website to s3 | |
run: | | |
aws s3 cp ./build s3://${{ env.BUCKET_NAME }}/ --recursive | |
- name: Invalidate Cloudfront distribution | |
run: | | |
aws cloudfront create-invalidation --distribution-id ${{ env.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |