Skip to content

Commit

Permalink
Update title of edited PRs only if base ref changed
Browse files Browse the repository at this point in the history
Also:
- Update title of reopened PRs too.
- Don't unnecessarily checkout the repo.
  • Loading branch information
nsoranzo committed Nov 22, 2024
1 parent 46c1dcd commit 09d8695
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pr-title-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ name: Update PR title

on:
pull_request_target:
types: [opened, edited]
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:
- uses: actions/checkout@v4
- name: Update PR title
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -23,5 +23,5 @@ jobs:
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"
gh pr edit $PR_NUMBER --repo "${{ github.repository }}" --title "$NEW_TITLE"
fi

0 comments on commit 09d8695

Please sign in to comment.