delete-review #5929
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: delete-review | |
on: delete | |
jobs: | |
delete-branch-environment: | |
runs-on: ubuntu-20.04 | |
environment: | |
name: review/${{ github.ref_name }} | |
env: | |
CI: true | |
AWS_PAGER: "" | |
BASE_URL: /${{ github.ref_name }}/ | |
AWS_DEFAULT_REGION: us-east-1 | |
AWS_EC2_METADATA_DISABLED: "true" | |
steps: | |
- name: Install awscli | |
uses: unfor19/install-aws-cli-action@v1 | |
- name: Remove files from S3 and invalidate Cloudfront path | |
env: | |
S3_BUCKET_NAME: ${{ secrets.REVIEW_S3_BUCKET_NAME }} | |
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.REVIEW_CLOUDFRONT_DISTRIBUTION_ID }} | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
aws s3 rm --recursive s3://${S3_BUCKET_NAME}${BASE_URL} | |
export INVALIDATION_ID=$( | |
aws cloudfront create-invalidation \ | |
--distribution-id $CLOUDFRONT_DISTRIBUTION_ID \ | |
--paths "${BASE_URL}*" \ | |
| jq -r .Invalidation.Id | |
) | |
aws cloudfront wait invalidation-completed \ | |
--id $INVALIDATION_ID \ | |
--distribution-id $CLOUDFRONT_DISTRIBUTION_ID |