Skip to content

Commit f4ab432

Browse files
authored
Merge pull request #19195 from arash77/pr-title-update-change-base
[24.0] Update PR title handling for changing base ref
2 parents d59f7a6 + afdfa78 commit f4ab432

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

.github/workflows/pr-title-update.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ name: Update PR title
33
on:
44
pull_request_target:
55
types: [opened, edited, reopened]
6-
branches:
7-
- "release_**"
86

97
jobs:
108
update-title:
@@ -19,9 +17,13 @@ jobs:
1917
PR_NUMBER: ${{ github.event.pull_request.number }}
2018
TARGET_BRANCH: "${{ github.base_ref }}"
2119
PR_TITLE: "${{ github.event.pull_request.title }}"
20+
REPO: "${{ github.repository }}"
2221
run: |
23-
VERSION=$(echo $TARGET_BRANCH | grep -oP '\d+\.\d+')
24-
if [[ -n "$VERSION" && ! "$PR_TITLE" =~ ^\[$VERSION\] ]]; then
25-
NEW_TITLE="[$VERSION] $PR_TITLE"
26-
gh pr edit $PR_NUMBER --repo "${{ github.repository }}" --title "$NEW_TITLE"
22+
VERSION=$(echo $TARGET_BRANCH | grep -oP '^release_\K\d+.\d+$' || true)
23+
NEW_TITLE=$(echo "$PR_TITLE" | sed -E "s/\[[0-9]+\.[0-9]+\] //")
24+
if [[ -n "$VERSION" ]]; then
25+
NEW_TITLE="[$VERSION] $NEW_TITLE"
26+
fi
27+
if [[ "$NEW_TITLE" != "$PR_TITLE" ]]; then
28+
gh pr edit $PR_NUMBER --repo "$REPO" --title "$NEW_TITLE"
2729
fi

0 commit comments

Comments
 (0)