Skip to content

fix(ci): teardown PR preview on branch delete, not PR close#97

Merged
posix4e merged 1 commit intomainfrom
fix/pr-teardown-on-branch-delete
Apr 15, 2026
Merged

fix(ci): teardown PR preview on branch delete, not PR close#97
posix4e merged 1 commit intomainfrom
fix/pr-teardown-on-branch-delete

Conversation

@posix4e
Copy link
Copy Markdown
Contributor

@posix4e posix4e commented Apr 15, 2026

Summary

Previously pr-teardown.yml triggered on pull_request: closed, which deletes the preview env even when the dev plans to reopen the PR. Switch the trigger to the delete event so:

  • Close-without-branch-delete → preview survives (dev can reopen and keep iterating)
  • Branch delete (manual, or GitHub's "delete branch on merge") → preview torn down

The delete event payload has no PR number, so the workflow resolves it from the branch name via gh pr list --head <branch> --state all. If no PR ever existed for the branch, it no-ops.

Test plan

  • YAML parses
  • Close a PR without deleting its branch → no teardown runs
  • Delete the branch → teardown runs, deletes VM + tunnel + DNS for that PR's preview
  • Delete a branch that never had a PR → workflow logs "no PR found" and exits clean

🤖 Generated with Claude Code

Closing a PR without deleting the branch usually means the dev
might reopen — keeping the preview up is the right default.
Branch delete (manual or via "delete branch on merge") is the
unambiguous end-of-life signal.

The delete event payload doesn't include the PR number, so the
workflow looks it up from the branch name via \`gh pr list --head
--state all\`. If no PR ever existed, it no-ops.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@posix4e posix4e merged commit fe706a7 into main Apr 15, 2026
1 check passed
@posix4e posix4e deleted the fix/pr-teardown-on-branch-delete branch April 16, 2026 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant