Fix PSR-18 compatibility #99
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Generate changelog when a MR is merged on main | |
permissions: | |
checks: write | |
pull-requests: write | |
contents: write | |
on: | |
pull_request: | |
branches: | |
- "main" | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v4" | |
with: | |
fetch-depth: 0 | |
fetch-tags: 'true' | |
- uses: actions/setup-go@v5 | |
- name: Generate Changelog | |
run: | | |
set -xve | |
git --no-pager log --oneline | |
go install github.com/git-chglog/git-chglog/cmd/git-chglog@latest || { echo "chglog installation failed. Please check the error above."; exit 1; } | |
git-chglog > CHANGELOG.md | |
cat CHANGELOG.md | |
- name: Changelog as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
overwrite: true | |
name: CHANGELOG.md | |
path: CHANGELOG.md | |
- name: Push Changelog Action | |
# Only push when it's a tag (i.e., after merge) | |
if: github.actor != 'GitHub Action Bot' && github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') | |
run: | | |
if [[ -n "$(git status --porcelain CHANGELOG.md)" ]]; then | |
git config user.name "GitHub Action Bot" | |
git config user.email "[email protected]" | |
git add CHANGELOG.md | |
git commit -m "ci(changelog): Update changelog" | |
git push origin HEAD:main | |
fi |