Create deploy.yml #1
This file contains hidden or 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 Website to S3 and CloudFront | |
| on: | |
| push: | |
| branches: | |
| - main # Trigger the workflow on push to the main branch | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Checkout the code | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| # Set up AWS CLI with credentials from GitHub secrets | |
| - name: Set up AWS CLI | |
| uses: aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| # Sync the website files to the S3 bucket | |
| - name: Sync website files to S3 | |
| run: | | |
| aws s3 sync ./ s3://vivek-resume-bucket-9 --exclude ".git/*" --exclude ".github/*" --delete | |
| # Syncs all files in the repo to the S3 bucket and removes any files not in the repo | |
| # Invalidate the CloudFront cache | |
| - name: Invalidate CloudFront Cache | |
| run: | | |
| aws cloudfront create-invalidation --distribution-id E2DAJWU03C66ZB --paths "/*" | |
| # Replace YOUR_CLOUDFRONT_DIST_ID with your CloudFront distribution ID |