Updated Code #11
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 Frontend to S3 | |
on: | |
push: | |
branches: | |
- main # or your default branch | |
paths: | |
- 'frontend/**' # Only trigger on changes to frontend folder | |
jobs: | |
deploy-frontend: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 # Replace with your preferred region | |
- name: Sync Frontend to S3 | |
run: | | |
aws s3 sync ./frontend s3://${{ secrets.S3_BUCKET_NAME }} \ | |
--delete \ | |
--exclude ".DS_Store" \ | |
--exclude "*.md" \ | |
--cache-control "max-age=86400" | |
- name: CloudFront Cache Invalidation | |
run: | | |
aws cloudfront create-invalidation \ | |
--distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \ | |
--paths "/*" | |
- name: Verify S3 Upload | |
run: | | |
aws s3 ls s3://${{ secrets.S3_BUCKET_NAME }} |