Skip to content

Updated Code

Updated Code #9

Workflow file for this run

name: Deploy to S3 and Invalidate CloudFront Cache
on:
push:
branches:
- main # Replace 'main' with your default branch if different
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
with:
aws-access-key-id: "${{ secrets.AWS_ACCESS_KEY_ID }}"
aws-secret-access-key: "${{ secrets.AWS_SECRET_ACCESS_KEY }}"
aws-region: "${{ secrets.AWS_REGION }}"
- name: Sync website files to S3
run: |
aws s3 sync . s3://${{ secrets.S3_BUCKET_NAME }} --delete
- name: Invalidate CloudFront cache
run: |
aws cloudfront create-invalidation \
--distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \
--paths "/*"
- name: List S3 bucket contents (optional for verification)
run: |
aws s3 ls s3://${{ secrets.S3_BUCKET_NAME }}