Skip to content

Deploy to S3 and Invalidate CloudFront with Assume Role #15

Deploy to S3 and Invalidate CloudFront with Assume Role

Deploy to S3 and Invalidate CloudFront with Assume Role #15

Workflow file for this run

name: Deploy to S3 and Invalidate CloudFront with Assume Role
on:
push:
branches:
- main
workflow_dispatch:
permissions:
id-token: write
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure AWS credentials using Assume Role
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: arn:aws:iam::195210670873:role/johnbrennan.codes-trust-role
aws-region: us-west-2
role-session-name: johnbrennan.codes-trust-role
- name: Sync S3 bucket
run: |
aws s3 sync . ${{ secrets.PORTFOLIO_BUCKET }} --delete
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.PORTFOLIO_CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"