Skip to content
Merged
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
33 changes: 33 additions & 0 deletions .github/workflows/validate-pr-source-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Validate PR Source Branch

on:
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- edited
- ready_for_review

permissions:
contents: read

jobs:
validate-source-branch:
name: Validate PR source branch
runs-on: ubuntu-latest
steps:
- name: Require feature or fix branch
shell: bash
env:
HEAD_REF: ${{ github.head_ref }}
run: |
if [[ "$HEAD_REF" =~ ^(feature|fix)-.+$ ]]; then
echo "Allowed source branch: $HEAD_REF"
exit 0
fi

echo "PRs targeting main must come from a branch named feature-* or fix-*. Current source branch: $HEAD_REF" >&2
exit 1