Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add workflow to update PR title based on target branch version #18835

Merged
merged 8 commits into from
Oct 14, 2024
27 changes: 27 additions & 0 deletions .github/workflows/pr-title-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Update PR Title If Target Branch Is A Version Branch
arash77 marked this conversation as resolved.
Show resolved Hide resolved

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 }}
nsoranzo marked this conversation as resolved.
Show resolved Hide resolved
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
TARGET_BRANCH=$(gh pr view $PR_NUMBER --json baseRefName -q .baseRefName)
arash77 marked this conversation as resolved.
Show resolved Hide resolved
PR_TITLE=$(gh pr view $PR_NUMBER --json title -q .title)
arash77 marked this conversation as resolved.
Show resolved Hide resolved
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
Loading