Skip to content

Commit 1c0885d

Browse files
committed
gha: check-pr-branch: fix branch check regression
This check was updated in f460110, but introduced some bugs; - the regular expressions were meant to define a capturing group, but the braces (`(`, `)`) were escaped (they previously were used by `sed`, which requires different escaping), so no value was captured. - the check itself was not updated to use the resulting `$target_branch` env-var, so was comparing against the `$GITHUB_BASE_REF` (which is the branch name before stripping minor versions). Signed-off-by: Sebastiaan van Stijn <[email protected]> (cherry picked from commit e0b98a3) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent fb3ec9f commit 1c0885d

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

.github/workflows/validate-pr.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,12 @@ jobs:
5757
id: title_branch
5858
run: |
5959
# get the intended major version prefix ("[27.1 backport]" -> "27.") from the PR title.
60-
[[ "$PR_TITLE" =~ ^\[\([0-9]*\.\)[^]]*\] ]] && branch="${BASH_REMATCH[1]}"
60+
[[ "$PR_TITLE" =~ ^\[([0-9]*\.)[^]]*\] ]] && branch="${BASH_REMATCH[1]}"
6161
6262
# get major version prefix from the release branch ("27.x -> "27.")
63-
[[ "$GITHUB_BASE_REF" =~ ^\([0-9]*\.\) ]] && target_branch="${BASH_REMATCH[1]}"
63+
[[ "$GITHUB_BASE_REF" =~ ^([0-9]*\.) ]] && target_branch="${BASH_REMATCH[1]}" || target_branch="$GITHUB_BASE_REF"
6464
65-
if [[ "$GITHUB_BASE_REF" != "$branch" ]] && ! [[ "$GITHUB_BASE_REF" == "master" && "$branch" == "" ]]; then
65+
if [[ "$target_branch" != "$branch" ]] && ! [[ "$GITHUB_BASE_REF" == "master" && "$branch" == "" ]]; then
6666
echo "::error::PR is opened against the $GITHUB_BASE_REF branch, but its title suggests otherwise."
6767
exit 1
6868
fi

0 commit comments

Comments
 (0)