Skip to content

Commit 245c94b

Browse files
Use built-in changelog PR creation (#61)
It turns out the `changelog-from-release` action supports creating the PR directly, so we don't need the manual PR creation steps. I found this because during testing it tried to push directly to the default branch which was denied by our branch protection rules. I've added a secondary checkout action since we will want to build and publish the actual released tag, but then push `CHANGELOG.md` changes to the default branch. This is a little confusing in the current state of this workflow file since there are no build/publish steps, so I've added a placeholder `TODO` to make it a bit clearer. By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.
1 parent f2cdc6f commit 245c94b

File tree

1 file changed

+13
-29
lines changed

1 file changed

+13
-29
lines changed

.github/workflows/release.yml

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,11 @@ name: Release
22

33
on:
44
release:
5-
types: [published]
6-
workflow_dispatch:
7-
inputs:
8-
tag_name:
9-
description: 'Tag name to simulate'
10-
required: true
11-
default: 'v0.0.0'
5+
types: [ published ]
126

137
permissions:
148
contents: write
9+
pull-requests: write
1510

1611
env:
1712
DEFAULT_BRANCH: version-0
@@ -20,33 +15,22 @@ jobs:
2015
update-changelog:
2116
runs-on: ubuntu-latest
2217
steps:
23-
- uses: actions/checkout@v4
18+
- name: Checkout tag for build & publish
19+
uses: actions/checkout@v4
2420
with:
2521
token: ${{ secrets.GITHUB_TOKEN }}
2622

23+
# TODO: Add build/publish steps here that use the tagged version
24+
25+
- name: Checkout default branch for changelog
26+
uses: actions/checkout@v4
27+
with:
28+
token: ${{ secrets.GITHUB_TOKEN }}
29+
ref: ${{ env.DEFAULT_BRANCH }}
30+
2731
- name: Update changelog
2832
uses: rhysd/changelog-from-release/action@v3
2933
with:
3034
file: CHANGELOG.md
3135
github_token: ${{ secrets.GITHUB_TOKEN }}
32-
33-
- name: Commit and push changelog
34-
run: |
35-
TAG_NAME="${{ github.event.release.tag_name || github.event.inputs.tag_name }}"
36-
BRANCH_NAME="changelog-update-$TAG_NAME"
37-
git checkout -b $BRANCH_NAME
38-
git config --local user.email "[email protected]"
39-
git config --local user.name "GitHub Action"
40-
git add CHANGELOG.md
41-
if ! git diff --staged --quiet; then
42-
git commit -m "Update CHANGELOG.md for $TAG_NAME"
43-
git push origin $BRANCH_NAME
44-
45-
gh pr create \
46-
--title "Update CHANGELOG.md for $TAG_NAME" \
47-
--body "Automated changelog update for release $TAG_NAME" \
48-
--base ${{ env.DEFAULT_BRANCH }} \
49-
--head $BRANCH_NAME
50-
fi
51-
env:
52-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
pull_request: true

0 commit comments

Comments
 (0)