From e5acd13f024fdbae27fd81b88f580b33e1a8a969 Mon Sep 17 00:00:00 2001 From: Arash Date: Tue, 17 Sep 2024 18:21:40 +0200 Subject: [PATCH] use branches instead of if in the job, add permissions --- .github/workflows/pr-title-update.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pr-title-update.yml b/.github/workflows/pr-title-update.yml index 35b7ef4fa8ad..30d99a1760ad 100644 --- a/.github/workflows/pr-title-update.yml +++ b/.github/workflows/pr-title-update.yml @@ -3,10 +3,14 @@ name: Update PR Title If Target Branch Is A Version Branch on: pull_request_target: types: [opened] + branches: + - 'release_**' jobs: update-title: runs-on: ubuntu-latest + permissions: + pull-requests: write steps: - name: Update PR title env: @@ -15,11 +19,8 @@ jobs: PR_NUMBER=${{ github.event.pull_request.number }} TARGET_BRANCH=$(gh pr view $PR_NUMBER --json baseRefName -q .baseRefName) PR_TITLE=$(gh pr view $PR_NUMBER --json title -q .title) - - if [[ "$TARGET_BRANCH" != "dev" ]]; then - 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 + 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