From 677c90bd0b79c2030d68850d7a14a862dfd6859a Mon Sep 17 00:00:00 2001 From: Arash Kadkhodaei Date: Thu, 17 Oct 2024 10:13:43 +0200 Subject: [PATCH] PR title update workflow --- .github/workflows/pr-title-update.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/pr-title-update.yml diff --git a/.github/workflows/pr-title-update.yml b/.github/workflows/pr-title-update.yml new file mode 100644 index 000000000000..6a4c5021f63d --- /dev/null +++ b/.github/workflows/pr-title-update.yml @@ -0,0 +1,27 @@ +name: Update PR title + +on: + pull_request_target: + types: [opened, edited] + branches: + - "release_**" + +jobs: + update-title: + runs-on: ubuntu-latest + permissions: + pull-requests: write + steps: + - uses: actions/checkout@v4 + - name: Update PR title + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + TARGET_BRANCH: "${{ github.base_ref }}" + PR_TITLE: "${{ github.event.pull_request.title }}" + 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 --title "$NEW_TITLE" + fi