Skip to content

♻️ Clean up staging preview for PR #106

♻️ Clean up staging preview for PR

♻️ Clean up staging preview for PR #106

---
name: Staging Deploy Cleanup
run-name: ♻️ Clean up staging preview for PR #${{ github.event.number }}
on:
pull_request:
types: [closed]
concurrency:
group: staging-cleanup-${{ github.event.number }}
cancel-in-progress: true
permissions:
contents: read
jobs:
cleanup:
name: Cleanup
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-slim
permissions:
id-token: write # for AWS OIDC authentication
env:
AWS_ROLE_ARN: arn:aws:iam::763944545891:role/pages-staging-oidc-overturemaps
AWS_REGION: us-west-2
steps:
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@517a711dbcd0e402f90c77e7e2f81e849156e31d # v6.2.2
with:
role-to-assume: ${{ env.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION }}
# No flags to ignore "not found" errors, so we use "|| true" to prevent failure if the path doesn't exist
- name: Delete from S3
run: |
aws s3 rm --recursive \
s3://overture-managed-staging-usw2/gh-pages/${GITHUB_EVENT_REPOSITORY_NAME}/pr/${GITHUB_EVENT_NUMBER}/ || true
aws s3 rm --recursive \
s3://overture-managed-staging-usw2/gh-pages/${GITHUB_EVENT_REPOSITORY_NAME}/pr/${GITHUB_EVENT_NUMBER}-no-autogen/ || true
env:
GITHUB_EVENT_REPOSITORY_NAME: ${{ github.event.repository.name }}
GITHUB_EVENT_NUMBER: ${{ github.event.number }}
- name: Bust the cache
run: |
aws cloudfront create-invalidation \
--distribution-id E1KP2IN0H2RGGT \
--paths "/${GITHUB_EVENT_REPOSITORY_NAME}/pr/${GITHUB_EVENT_NUMBER}/*" || true
env:
GITHUB_EVENT_REPOSITORY_NAME: ${{ github.event.repository.name }}
GITHUB_EVENT_NUMBER: ${{ github.event.number }}