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
30 changes: 30 additions & 0 deletions .github/workflows/pr-branch-policy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: PR Branch Policy

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

permissions: {}

jobs:
validate-pr-flow:
runs-on: ubuntu-latest
steps:
- name: Validate source and target branches
env:
BASE_REF: ${{ github.event.pull_request.base.ref }}
HEAD_REF: ${{ github.event.pull_request.head.ref }}
run: |
if [ "$BASE_REF" = "dev" ]; then
echo "Allowed: any branch can open PR to dev."
exit 0
fi

if [ "$BASE_REF" = "main" ] && [ "$HEAD_REF" = "dev" ]; then
echo "Allowed: only dev can open PR to main."
exit 0
fi

echo "Blocked: PR flow must be <any-branch -> dev> or <dev -> main>."
echo "Current flow: $HEAD_REF -> $BASE_REF"
exit 1
Loading