Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/trunk-guard.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Trunk guard

# Only the `trunk` branch of THIS repository may merge into main. Feature
# branches merge into `trunk`; CI runs only on the trunk -> main PR.
#
# The head-repo check is load-bearing: `github.head_ref` is just the branch
# name, so a fork whose head branch is also called `trunk` would otherwise
# skip the guard and merge straight into main.
on:
pull_request:
branches: [main]

jobs:
only-trunk-merges-to-main:
if: >-
github.event.pull_request.head.repo.full_name != github.repository
|| github.head_ref != 'trunk'
runs-on: ubuntu-latest
timeout-minutes: 1
steps:
- run: |
echo "::error::Only the 'trunk' branch of ${{ github.repository }} may merge into main. Retarget this PR to 'trunk'."
exit 1
Loading