Skip to content

Commit

Permalink
Add workflow to update PR title based on target branch version
Browse files Browse the repository at this point in the history
  • Loading branch information
arash77 committed Sep 17, 2024
1 parent 5acc518 commit 4160c31
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/pr-title-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Update PR Title If Target Branch Is A Version Branch

on:
pull_request:
types: [opened]

jobs:
update-title:
runs-on: ubuntu-latest
steps:
- name: Update PR title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
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
fi

0 comments on commit 4160c31

Please sign in to comment.