fix(ci): cleanup-pr-preview workflow not firing on PR close#14
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
WalkthroughThe PR fixes a GitHub Actions workflow authorization failure by renaming the PR preview cleanup workflow and removing an invalid Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
.github/workflows/pr-preview-cleanup.yml (1)
70-81:⚠️ Potential issue | 🟠 Major | ⚡ Quick winEnsure Neon cleanup still runs when Cloudflare cleanup fails.
On Line 75, Neon cleanup is currently skipped if Line 73 fails, because step execution stops on failure unless
if: always()is set. That can leave stalepreview/pr-*branches behind again.Suggested fix
- name: Delete Neon PR branch + if: ${{ always() && steps.pr.outputs.number != '' }} uses: neondatabase/delete-branch-action@v3 continue-on-error: true with: project_id: ${{ vars.NEON_PROJECT_ID }} branch: preview/pr-${{ steps.pr.outputs.number }} api_key: ${{ secrets.NEON_API_KEY }}🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In @.github/workflows/pr-preview-cleanup.yml around lines 70 - 81, The "Delete Neon PR branch" step currently depends on normal success of previous steps and will be skipped if the "Delete Cloudflare PR resources" step fails; update the "Delete Neon PR branch" job step (named "Delete Neon PR branch") to include an execution condition so it always runs regardless of earlier failures—add if: always() to that step so Neon branch cleanup runs even when the Cloudflare cleanup node script fails.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Outside diff comments:
In @.github/workflows/pr-preview-cleanup.yml:
- Around line 70-81: The "Delete Neon PR branch" step currently depends on
normal success of previous steps and will be skipped if the "Delete Cloudflare
PR resources" step fails; update the "Delete Neon PR branch" job step (named
"Delete Neon PR branch") to include an execution condition so it always runs
regardless of earlier failures—add if: always() to that step so Neon branch
cleanup runs even when the Cloudflare cleanup node script fails.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: d843b8f4-10b1-47d0-a2d9-41cf2cc4d3c4
📒 Files selected for processing (4)
.github/workflows/pr-preview-cleanup.yml.gitignoredocs/ops/first-deploy.mddocs/ops/project-status.md
PR #2 added `permissions: administration: write` to the cleanup workflow, but `administration` is not a valid GITHUB_TOKEN scope. GitHub rejected the workflow at evaluation time, silently dropping every `pull_request.closed` event for PRs #2--#9 and accumulating eight stale `preview/pr-N` Neon branches that tripped the 10-branch free-tier cap (blocks PR #10/#11/#12 deploys with HTTP 422). Drop the invalid permission and the `deleteAnEnvironment` step that required it; rename the file so GitHub registers a fresh workflow id instead of reusing the wedged record; validate the resolved PR number is a positive integer before deleting anything. Stale Neon branches still need a one-time operator purge -- agent is forbidden from calling `neondatabase/delete-branch-action` autonomously. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
8bff59e to
2a3ec50
Compare
|
agent-paste PR preview resources were cleaned up. The pr-preview-${context.issue.number} environment is left in place; remove it from the GitHub UI if desired. |
Why
PR #2 added
permissions: administration: writeto the cleanup workflow, butadministrationis not a validGITHUB_TOKENscope (only fine-grained PATs accept it). GitHub silently rejected the workflow at evaluation time, dropping everypull_request.closedevent for PRs #2--#9 and accumulating 8 stalepreview/pr-NNeon branches that tripped the 10-branch free-tier cap (blocked PR #10/#11/#12 deploys with HTTP 422).Diagnosis
Three signals confirmed the workflow record was wedged:
gh api repos/zaks-io/agent-paste/actions/workflows/281097778returned"name": ".github/workflows/cleanup-pr-preview.yml"(the path), not"Cleanup PR Preview"from the YAMLname:field. Other workflows returned their YAML name correctly.gh api '.../actions/runs?per_page=100' --paginateshowed exactly oneevent=pull_requestrun (PR feat(apex): add marketing worker at agent-paste.sh #1 close, before PR ci(pr-preview): register dynamic GitHub deployment per PR #2 introduced the invalid permission) and 38event=pushstartup_failures.GITHUB_TOKENpermission keys;administrationis not in the list.Changes
.github/workflows/cleanup-pr-preview.yml→.github/workflows/pr-preview-cleanup.yml(rename forces GitHub to register a fresh workflow id; the old record is wedged and will keep ignoring close events even after the YAML is fixed).permissions: administration: writeand thedeleteAnEnvironmentstep that needed it. Per-PRpr-preview-Nenvironments are cheap; operator can purge from the UI if desired.docs/ops/first-deploy.md: update workflow filename reference.docs/ops/project-status.md: flip "PR cleanup workflow" row to "Re-registered" and add a Recently Completed entry capturing root cause + operator follow-up..gitignore: add.agent-out/so coderabbit artifacts stay local.Risk
Test plan
pnpm verifygreen locally (49/49 turbo tasks, Node 24.15.0).coderabbit review --agent --base main); see disposition below.neondatabase/delete-branch-action@v3which is exactly the autonomous Neon delete that is gated on Isaac's approval). Once PR feat(api,upload,content): add X-Request-Id and request_id to envelope #10/chore(branches): close obsolete t3code branches #11/docs(ops): add Logpush -> Axiom runbook for click-ops #12 merges, the new workflow id should register and fire on close; checkgh api repos/zaks-io/agent-paste/actions/workflowsfor a NEW workflow id withname: "PR Preview Cleanup".preview/pr-2throughpreview/pr-9Neon branches via console.CodeRabbit findings
.agent-out/cleanup-fix-cr.json:2-- trailing newline. Skipped: generated artifact, not committed (now gitignored)..agent-out/cleanup-fix-cr.json:1-- artifact should not be tracked. Accepted: added.agent-out/to.gitignore..github/workflows/pr-preview-cleanup.yml:52-59-- PR number lacks validation. Accepted: added^[1-9][0-9]*$regex check inResolve PR number..github/workflows/pr-preview-cleanup.yml:13-16--administration: writeis not a valid permission. Accepted: this was the actual root cause; removed the key and the step that required it.Summary by CodeRabbit
Release Notes
Bug Fixes
Documentation