update actions #6
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 Hugo Site to S3 with OIDC | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
deploy-to-prod: | |
runs-on: ubuntu-latest | |
environment: prod | |
permissions: | |
id-token: write | |
contents: read | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Get AWS credentials using OIDC | |
id: assume-role | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-region: ${{ secrets.AWS_REGION }} | |
role-to-assume: ${{ secrets.AWS_DEPLOY_ROLE_ARN }} | |
role-session-name: hugo-deploy-${{ github.run_id }} | |
- name: Set up Hugo | |
uses: peaceiris/actions-hugo@v2 | |
with: | |
hugo-version: latest | |
- name: Build the Hugo site | |
run: hugo | |
- name: Deploy to S3 | |
run: hugo deploy --target prod # Change target to a var if you have multiple target envs | |
- name: Invalidate CloudFront cache (optional) | |
run: aws cloudfront create-invalidation --distribution-id ${{secrets.AWS_CLOUDFRONT_DISTRIBUTION_ID}} --paths "/*" |