One click deploy and cleanup (#1) #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 CloudFormation Template to S3 | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'infrastructure/templates/cloudfront.yaml' | |
| - 'infrastructure/templates/remove-cloudfront.yaml' | |
| workflow_dispatch: | |
| jobs: | |
| deploy-template: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| id-token: write | |
| contents: read | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| role-to-assume: ${{ secrets.AWS_ROLE_ARN }} | |
| aws-region: ${{ vars.AWS_REGION }} | |
| - name: Upload CloudFormation templates to S3 | |
| run: | | |
| echo "Uploading CloudFront template to s3://${{ vars.S3_BUCKET }}/${{ vars.S3_FILE_KEY }}" | |
| aws s3 cp infrastructure/templates/cloudfront.yaml s3://${{ vars.S3_BUCKET }}/${{ vars.S3_FILE_KEY }} | |
| echo "Uploading cleanup template to s3://${{ vars.S3_BUCKET }}/remove-cloudfront.yaml" | |
| aws s3 cp infrastructure/templates/remove-cloudfront.yaml s3://${{ vars.S3_BUCKET }}/remove-cloudfront.yaml | |
| # Verify uploads | |
| echo "Verifying template accessibility..." | |
| curl -f -I https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/${{ vars.S3_FILE_KEY }} | |
| curl -f -I https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/remove-cloudfront.yaml | |
| echo "✅ Templates successfully deployed!" | |
| echo "CloudFront Template URL: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/${{ vars.S3_FILE_KEY }}" | |
| echo "Cleanup Template URL: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/remove-cloudfront.yaml" | |
| - name: Update deployment status | |
| run: | | |
| echo "::notice title=Templates Deployed::CloudFormation templates updated - CloudFront: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/${{ vars.S3_FILE_KEY }}, Cleanup: https://${{ vars.S3_BUCKET }}.s3.amazonaws.com/remove-cloudfront.yaml" |