Skip to content

Commit 4959bfc

Browse files
authored
Add github-changelog-generator CI workflow (#421)
* Add github-changelog-generator CI workflow * specify version * push with action * fetch/merge * use fetch-depth: 0 * only run at push to main * make auto changelog manually triggered * Checkout commit * Cat CHANGELOG
1 parent c22ea54 commit 4959bfc

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Generate Changelog
2+
3+
on:
4+
# Manual trigger only
5+
workflow_dispatch:
6+
7+
jobs:
8+
generate-changelog:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
16+
- name: Force-checkout latest commit on branch
17+
run: |
18+
git fetch
19+
git reset --hard origin/${{ github.head_ref }}
20+
21+
- name: Setup Ruby
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
ruby-version: 3.0
25+
26+
- name: Install github-changelog-generator
27+
run: gem install github_changelog_generator
28+
29+
- name: Generate Changelog
30+
run: |
31+
github_changelog_generator \
32+
-u ${{ github.repository_owner }} \
33+
-p ${{ github.event.repository.name }} \
34+
--token ${{ secrets.GITHUB_TOKEN }} \
35+
--output CHANGELOG.md
36+
37+
- name: Commit updated CHANGELOG.md
38+
id: commit
39+
run: |
40+
git add CHANGELOG.md
41+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
42+
git config --local user.name "github-actions[bot]"
43+
if git diff --quiet && git diff --staged --quiet; then
44+
echo "No changes in CHANGELOG.md, skipping commit."
45+
echo "commit_status=skipped" >> $GITHUB_ENV
46+
else
47+
git commit -m "Update CHANGELOG.md"
48+
echo "commit_status=committed" >> $GITHUB_ENV
49+
fi
50+
51+
- name: Echo CHANGELOG.md
52+
run: cat CHANGELOG.md
53+
54+
- name: Push changes
55+
if: env.commit_status == 'committed'
56+
uses: ad-m/github-push-action@master
57+
with:
58+
github_token: ${{ secrets.GITHUB_TOKEN }}
59+
branch: ${{ github.head_ref }}

0 commit comments

Comments
 (0)