From 84da98cb731502b0b6258552cf996141384474dc Mon Sep 17 00:00:00 2001 From: razorblade23 <81590614+razorblade23@users.noreply.github.com> Date: Sat, 5 Sep 2026 16:50:20 +0200 Subject: [PATCH] Refactor cleanup-preview to delete branch via API Updated the cleanup-preview job to use API for branch deletion. --- .github/workflows/preview-changes.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/preview-changes.yml b/.github/workflows/preview-changes.yml index cee27d6..b3355b6 100644 --- a/.github/workflows/preview-changes.yml +++ b/.github/workflows/preview-changes.yml @@ -111,24 +111,24 @@ jobs: issue_number: prNumber, body: message, }); - # CLEANUP PREVIEW: Triggered when the PR is closed or merged + + # CLEANUP PREVIEW: Triggered when the PR is closed or merged cleanup-preview: name: Delete Cloudflare Pages Preview if: github.event.action == 'closed' runs-on: ubuntu-latest steps: - - name: Setup Node.js - uses: actions/setup-node@v4 - with: - node-version: 20 - - - name: Delete Cloudflare Pages Branch + - name: Delete Cloudflare Pages Branch via API env: CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} run: | BRANCH_NAME="pr-${{ github.event.number }}" - echo "Deleting Cloudflare Pages deployment alias for branch: $BRANCH_NAME" + PROJECT_NAME="python-ledger-preview" + + echo "Deleting Cloudflare Pages branch: $BRANCH_NAME" - # Force delete the alias/branch deployments - npx wrangler pages deployment delete --project-name=python-ledger-preview "pr-${{ github.event.number }}" --force + curl -s -X DELETE \ + "https://api.cloudflare.com/client/v4/accounts/${CLOUDFLARE_ACCOUNT_ID}/pages/projects/${PROJECT_NAME}/branches/${BRANCH_NAME}" \ + -H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}" \ + -H "Content-Type: application/json"