Skip to content

Commit

Permalink
Merge pull request #19195 from arash77/pr-title-update-change-base
Browse files Browse the repository at this point in the history
[24.0] Update PR title handling for changing base ref
  • Loading branch information
martenson authored Nov 29, 2024
2 parents d59f7a6 + afdfa78 commit f4ab432
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions .github/workflows/pr-title-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Update PR title
on:
pull_request_target:
types: [opened, edited, reopened]
branches:
- "release_**"

jobs:
update-title:
Expand All @@ -19,9 +17,13 @@ jobs:
PR_NUMBER: ${{ github.event.pull_request.number }}
TARGET_BRANCH: "${{ github.base_ref }}"
PR_TITLE: "${{ github.event.pull_request.title }}"
REPO: "${{ github.repository }}"
run: |
VERSION=$(echo $TARGET_BRANCH | grep -oP '\d+\.\d+')
if [[ -n "$VERSION" && ! "$PR_TITLE" =~ ^\[$VERSION\] ]]; then
NEW_TITLE="[$VERSION] $PR_TITLE"
gh pr edit $PR_NUMBER --repo "${{ github.repository }}" --title "$NEW_TITLE"
VERSION=$(echo $TARGET_BRANCH | grep -oP '^release_\K\d+.\d+$' || true)
NEW_TITLE=$(echo "$PR_TITLE" | sed -E "s/\[[0-9]+\.[0-9]+\] //")
if [[ -n "$VERSION" ]]; then
NEW_TITLE="[$VERSION] $NEW_TITLE"
fi
if [[ "$NEW_TITLE" != "$PR_TITLE" ]]; then
gh pr edit $PR_NUMBER --repo "$REPO" --title "$NEW_TITLE"
fi

0 comments on commit f4ab432

Please sign in to comment.