Skip to content

Commit 30f8908

Browse files
vvolandaustinvazquez
authored andcommitted
github/ci: Check if backport is opened against the expected branch
Signed-off-by: Paweł Gronowski <[email protected]> (cherry picked from commit 61269e7) Signed-off-by: Austin Vazquez <[email protected]>
1 parent 65cc597 commit 30f8908

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

.github/workflows/validate-pr.yml

+16
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,19 @@ jobs:
4444
4545
echo "This PR will be included in the release notes with the following note:"
4646
echo "$desc"
47+
48+
check-pr-branch:
49+
runs-on: ubuntu-20.04
50+
env:
51+
PR_TITLE: ${{ github.event.pull_request.title }}
52+
steps:
53+
# Backports or PR that target a release branch directly should mention the target branch in the title, for example:
54+
# [X.Y backport] Some change that needs backporting to X.Y
55+
# [X.Y] Change directly targeting the X.Y branch
56+
- name: Get branch from PR title
57+
id: title_branch
58+
run: echo "$PR_TITLE" | sed -n 's/^\[\([0-9]*\.[0-9]*\)[^]]*\].*/branch=\1/p' >> $GITHUB_OUTPUT
59+
60+
- name: Check release branch
61+
if: github.event.pull_request.base.ref != steps.title_branch.outputs.branch && !(github.event.pull_request.base.ref == 'master' && steps.title_branch.outputs.branch == '')
62+
run: echo "::error::PR title suggests targetting the ${{ steps.title_branch.outputs.branch }} branch, but is opened against ${{ github.event.pull_request.base.ref }}" && exit 1

0 commit comments

Comments
 (0)