adding unfinished post #4
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
# Workflow name | |
name: S3 Deploy | |
on: | |
workflow_dispatch: | |
push: | |
paths: | |
- 'app/**' | |
- '.github/workflows/deploy.yml' | |
branches: | |
- master | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: sa-east-1 | |
BUCKET_NAME: caiogomes.me | |
steps: | |
- name: Install hugo | |
run: sudo apt install hugo | |
- name: configure aws credentials | |
uses: aws-actions/[email protected] | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
role-session-name: GitHub_to_AWS_via_FederatedOIDC | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: 'true' | |
- name: Build | |
run: cd app/ && hugo | |
- name: Upload files to S3 | |
run: aws s3 sync app/public/ s3://${{ env.BUCKET_NAME }}/ --exact-timestamps --delete | |
create-cloudfront-invalidation: | |
needs: build-and-deploy | |
runs-on: ubuntu-latest | |
env: | |
AWS_REGION: sa-east-1 | |
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} | |
steps: | |
- name: configure aws credentials | |
uses: aws-actions/[email protected] | |
with: | |
role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
role-session-name: GitHub_to_AWS_via_FederatedOIDC | |
aws-region: ${{ env.AWS_REGION }} | |
- name: Invalidate clodufront distribution | |
run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*" |