Skip to content

Cloudflare Pages Cleanup #16

Cloudflare Pages Cleanup

Cloudflare Pages Cleanup #16

name: Cloudflare Pages Cleanup
on:
pull_request:
types:
- closed
check_run:
types:
- completed
permissions:
contents: read
jobs:
cleanup-pr:
name: Cleanup closed PR previews
if: >-
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
concurrency:
group: cloudflare-pages-cleanup-pr-${{ github.event.pull_request.head.ref }}
cancel-in-progress: false
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cleanup Cloudflare Pages deployments
env:
CF_ACCOUNT_ID: ${{ vars.CF_ACCOUNT_ID }}
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CF_PAGES_PROJECT_NAME: ${{ vars.CF_PAGES_PROJECT_NAME }}
CLEANUP_MODE: pr-closed
PR_BRANCH: ${{ github.event.pull_request.head.ref }}
run: .github/workflows/scripts/cloudflare-pages-deploy-cleanup.sh
cleanup-production:
name: Cleanup previews after production deploy
if: >-
github.event_name == 'check_run' && github.event.check_run.app.slug ==
'cloudflare-workers-and-pages' && github.event.check_run.name ==
'Cloudflare Pages' && github.event.check_run.status == 'completed' &&
github.event.check_run.conclusion == 'success' &&
github.event.check_run.check_suite != null &&
github.event.check_run.check_suite.head_branch != null &&
github.event.check_run.check_suite.head_branch ==
github.event.repository.default_branch
runs-on: ubuntu-latest
concurrency:
group: cloudflare-pages-cleanup-production-${{
github.event.repository.default_branch }}
cancel-in-progress: false
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Cleanup Cloudflare Pages deployments
env:
CF_ACCOUNT_ID: ${{ vars.CF_ACCOUNT_ID }}
CF_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
CF_PAGES_PROJECT_NAME: ${{ vars.CF_PAGES_PROJECT_NAME }}
CLEANUP_MODE: post-production
PRODUCTION_ALIAS: ${{ vars.CF_PAGES_PRODUCTION_ALIAS || 'https://koutyuke.dev' }}
PRODUCTION_BRANCH: ${{ vars.CF_PAGES_PRODUCTION_BRANCH ||
github.event.repository.default_branch }}
run: .github/workflows/scripts/cloudflare-pages-deploy-cleanup.sh