From afdfa789f171963cdcb0509a442a7196be70861c Mon Sep 17 00:00:00 2001 From: Arash Date: Tue, 26 Nov 2024 12:20:19 +0100 Subject: [PATCH] Refactor version extraction in PR title update workflow for improved accuracy Co-authored-by: Nicola Soranzo --- .github/workflows/pr-title-update.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-title-update.yml b/.github/workflows/pr-title-update.yml index 6ed945cae0f7..8ffd54a45da4 100644 --- a/.github/workflows/pr-title-update.yml +++ b/.github/workflows/pr-title-update.yml @@ -19,11 +19,10 @@ jobs: PR_TITLE: "${{ github.event.pull_request.title }}" REPO: "${{ github.repository }}" run: | - VERSION=$(echo $TARGET_BRANCH | grep -oP 'release_\K.*' || true) + 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] ${PR_TITLE#*\] }" - else - NEW_TITLE="${PR_TITLE#*\] }" + NEW_TITLE="[$VERSION] $NEW_TITLE" fi if [[ "$NEW_TITLE" != "$PR_TITLE" ]]; then gh pr edit $PR_NUMBER --repo "$REPO" --title "$NEW_TITLE"