Skip to content

Commit

Permalink
use branches instead of if in the job, add permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Sep 17, 2024
1 parent 17a124e commit e5acd13
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/pr-title-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit e5acd13

Please sign in to comment.