Repository navigation
ci: harden trunk gating #488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ jobs: | |
| cleanup-preview: | ||
| name: Cleanup Preview | ||
| if: >- | ||
| ((github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || github.head_ref == 'trunk') && | ||
| ((github.event_name != 'pull_request' && github.event_name != 'pull_request_target') || (github.head_ref == 'trunk' && github.event.pull_request.head.repo.full_name == github.repository && github.base_ref == 'main')) && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Closed cleanup remains trunk-gatedMedium Severity
Reviewed by Cursor Bugbot for commit 37c3236. Configure here. |
||
| (github.event.action == 'closed' && (github.event.pull_request.merged == true || github.event.pull_request.state == 'closed') && github.event.pull_request.head.repo.full_name == github.repository) | ||
| runs-on: ubuntu-latest | ||
| env: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,22 @@ | ||
| name: Trunk guard | ||
|
|
||
| # Only the `trunk` branch may merge into main. Feature branches merge into | ||
| # `trunk` (via the merge train); CI runs only on the trunk -> main PR. | ||
| # Only this repository's `trunk` branch may merge into main. Feature branches | ||
| # merge into `trunk`; CI runs only on the trunk -> main PR. | ||
| # pull_request_target loads this workflow from the base branch, so a PR cannot | ||
| # edit the guard to pass itself. It never checks out PR code. | ||
| on: | ||
| pull_request: | ||
| pull_request_target: | ||
| branches: [main] | ||
| types: [opened, synchronize, reopened, edited] | ||
|
|
||
| permissions: {} | ||
|
|
||
| jobs: | ||
| only-trunk-merges-to-main: | ||
| if: github.head_ref != 'trunk' | ||
| if: github.head_ref != 'trunk' || github.event.pull_request.head.repo.full_name != github.repository | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 1 | ||
| steps: | ||
| - run: | | ||
| echo "::error::Only the 'trunk' branch may merge into main. Retarget this PR to 'trunk'." | ||
| echo "::error::Only this repository's 'trunk' branch may merge into main. Retarget this PR to 'trunk'." | ||
| exit 1 |


There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Closed preview workers remain deployed
When a feature PR with a preview worker closes,
cleanup-previewskips deletion because its head is nottrunk. The worker remains deployed after the PR closes.Learn more
Preview workers were previously deployed for same-repository feature PRs by the deploy-preview job before trunk gating removed it. The current cleanup job runs only on
closedevents, but the trunk-only predicate discards those events for feature PRs. The remaining predicate already restricts deletion to same-repository PRs, and a closed PR always has a closed state. This leaves previously deployed workers active unless the separate audit runs in removal mode.Example: PR #400 deployed
relaycast-pr-400before trunk gating. Closing PR #400 fromfeature/searchskips cleanup, leaving the worker active instead of deleting it.Recommended fix: Gate
cleanup-previewonly on a closed event from the same repository. Keep the existing same-repository restriction and delete both worker names as before.Was this helpful? React with 👍 or 👎 to provide feedback.