Skip to content
Draft
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
31 changes: 31 additions & 0 deletions .github/workflows/check-pr-target-branch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Check PR target branch

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

permissions: {}

jobs:
check-pr-target-branch:
name: Check PR target branch
runs-on: ubuntu-slim

steps:
- name: Validate source and target branch
shell: bash
env:
SOURCE_BRANCH: ${{ github.event.pull_request.head.ref }}
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
run: |
echo "Source branch: ${SOURCE_BRANCH}"
echo "Target branch: ${TARGET_BRANCH}"

main_target_branch_regex='^[0-9]+\.[0-9]+\.[0-9]+/(release)$'

if [[ "${TARGET_BRANCH}" == "main" && ! "${SOURCE_BRANCH}" =~ ${main_target_branch_regex} ]]; then
echo "::warning title=Wrong PR target branch::Branch '${SOURCE_BRANCH}' targets 'main'. Only '<x.y.z>/release' branches are expected to target 'main'. Feature and fix branches should target their matching release branch instead, for example '2.5.2/release'."
exit 1
fi

echo "PR target branch looks OK."
Loading