Skip to content
Open
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
29 changes: 29 additions & 0 deletions .github/workflows/assert-base-is-default-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: PR base guard

# Reject PRs whose base is not the repo's default branch.
# Stacked PRs (PR-on-PR) are not supported here: under squash merge the
# downstream PR's base ref still points at the pre-squash commits, so the
# chain silently desyncs. Branch from the default branch and merge serially.

on:
pull_request:
types: [opened, reopened, edited, synchronize]

permissions: {}

jobs:
base-must-be-default:
runs-on: ubuntu-latest
steps:
- name: Reject if base is not the default branch
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
if [ "$BASE_REF" != "$DEFAULT_BRANCH" ]; then
echo "::error::PR #${PR_NUMBER} base is '${BASE_REF}', must be '${DEFAULT_BRANCH}'."
echo "Stacked PRs are not supported. Branch from '${DEFAULT_BRANCH}' and merge serially."
exit 1
fi
echo "OK: base '${BASE_REF}' matches default branch."
Loading