Skip to content

[24.0] Update title of edited PRs only if base ref changed #44

[24.0] Update title of edited PRs only if base ref changed

[24.0] Update title of edited PRs only if base ref changed #44

Workflow file for this run

name: Update PR title
on:
pull_request_target:
types: [opened, edited, reopened]
branches:
- "release_**"
jobs:
update-title:
if: github.event.action != 'edited' || github.event.changes.base.ref.from != ''
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- 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 --repo "${{ github.repository }}" --title "$NEW_TITLE"
fi