diff --git a/.github/workflows/pr-title-update.yml b/.github/workflows/pr-title-update.yml index ee47e16d84e1..8ffd54a45da4 100644 --- a/.github/workflows/pr-title-update.yml +++ b/.github/workflows/pr-title-update.yml @@ -3,8 +3,6 @@ name: Update PR title on: pull_request_target: types: [opened, edited, reopened] - branches: - - "release_**" jobs: update-title: @@ -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