Skip to content

Demo Preview Cleanup #69

Demo Preview Cleanup

Demo Preview Cleanup #69

name: Demo Preview Cleanup
on:
schedule:
- cron: '0 12 * * *' # every day at noon
permissions:
id-token: write # This is required for requesting the OIDC JWT for authing with Azure
contents: read # This is required for actions/checkout
pull-requests: read # Required to list PRs
# This allows one deploy workflow to interrupt another
concurrency:
group: 'preview-env-cleanup @ ${{ github.head_ref || github.run_id }} for ${{ github.event.inputs.PR_NUMBER }}'
cancel-in-progress: true
jobs:
cleanup:
name: Cleanup
runs-on: ubuntu-latest
timeout-minutes: 5
environment:
name: preview
steps:
- uses: Azure/login@v2
with:
# excluding a client secret here will cause a login via OpenID Connect (OIDC),
# which prevents us from having to rotate client credentials, etc
client-id: ${{ secrets.AZURE_CLIENT_ID }}
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
# Do this before repo checkout to prevent running bundle install
- uses: ruby/setup-ruby@v1
with:
ruby-version: '3.3'
- name: Check out repo
uses: actions/checkout@v4
# Delete web app (which will also delete the App Service plan)
# This will succeed even if the app doesn't exist / has already been deleted
- name: 'Delete App Service Apps for closed PRs'
run: ruby ./.github/workflows/demo-preview-cleanup.rb
env:
GITHUB_TOKEN: ${{ github.token }}