Skip to content

Commit d2a8d19

Browse files
committed
gha: check-pr-branch: verify major version only
We'll be using release branches for minor version updates, so instead of (e.g.) a 27.0 branch, we'll be using 27.x and continue using the branch for minor version updates. This patch changes the validation step to only compare against the major version. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3a62d49 commit d2a8d19

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

.github/workflows/validate-pr.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,20 @@ jobs:
4949
runs-on: ubuntu-20.04
5050
env:
5151
PR_TITLE: ${{ github.event.pull_request.title }}
52+
TARGET_BRANCH: ${{ github.event.pull_request.base.ref }}
5253
steps:
5354
# Backports or PR that target a release branch directly should mention the target branch in the title, for example:
5455
# [X.Y backport] Some change that needs backporting to X.Y
5556
# [X.Y] Change directly targeting the X.Y branch
5657
- name: Get branch from PR title
5758
id: title_branch
58-
run: echo "$PR_TITLE" | sed -n 's/^\[\([0-9]*\.[0-9]*\)[^]]*\].*/branch=\1/p' >> $GITHUB_OUTPUT
59+
run: |
60+
# get the intended major version prefix ("[27.1 backport]" -> "27.") from the PR title.
61+
echo "$PR_TITLE" | sed -n 's/^\[\([0-9]*\.\)[^]]*\].*/branch=\1/p' >> $GITHUB_OUTPUT
62+
63+
# get major version prefix from the release branch ("27.x -> "27.")
64+
echo "$TARGET_BRANCH" | sed -n 's/^\([0-9]*\.\).*/target_branch=\1/p' >> $GITHUB_OUTPUT
5965
6066
- 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 == '')
67+
if: steps.title_branch.outputs.target_branch != steps.title_branch.outputs.branch && !(github.event.pull_request.base.ref == 'master' && steps.title_branch.outputs.branch == '')
6268
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)