|
| 1 | +name: "Update Changelog" |
| 2 | + |
| 3 | +on: |
| 4 | + release: |
| 5 | + types: [published] |
| 6 | + workflow_dispatch: |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | + pull-requests: write |
| 11 | + |
| 12 | +jobs: |
| 13 | + update-changelog: |
| 14 | + runs-on: ubuntu-latest |
| 15 | + steps: |
| 16 | + - name: Checkout code |
| 17 | + uses: actions/checkout@v4 |
| 18 | + with: |
| 19 | + fetch-depth: 0 |
| 20 | + ref: main |
| 21 | + |
| 22 | + - name: Setup git-chglog |
| 23 | + run: | |
| 24 | + CHGLOG_VERSION="0.9.1" |
| 25 | + curl -o git-chglog -L "https://github.com/git-chglog/git-chglog/releases/download/${CHGLOG_VERSION}/git-chglog_linux_amd64" |
| 26 | + chmod +x git-chglog |
| 27 | +
|
| 28 | + - name: Generate CHANGELOG.md |
| 29 | + id: generate |
| 30 | + run: | |
| 31 | + rm -f CHANGELOG.md |
| 32 | + ./git-chglog -o CHANGELOG.md |
| 33 | + if git diff --quiet CHANGELOG.md; then |
| 34 | + echo "changes=false" >> $GITHUB_OUTPUT |
| 35 | + else |
| 36 | + echo "changes=true" >> $GITHUB_OUTPUT |
| 37 | + fi |
| 38 | + env: |
| 39 | + GITHUB_TOKEN: ${{ secrets.CHANGELOG_TOKEN }} |
| 40 | + |
| 41 | + - name: Cleanup |
| 42 | + run: rm git-chglog |
| 43 | + if: always() |
| 44 | + |
| 45 | + - name: Create Pull Request |
| 46 | + if: steps.generate.outputs.changes == 'true' |
| 47 | + uses: peter-evans/create-pull-request@v4 |
| 48 | + with: |
| 49 | + token: ${{ secrets.CHANGELOG_TOKEN }} |
| 50 | + commit-message: "chore: update CHANGELOG.md" |
| 51 | + title: "📝 Update Changelog" |
| 52 | + body: | |
| 53 | + This PR updates the CHANGELOG.md to include all releases. |
| 54 | + - Generated using git-chglog |
| 55 | + - Triggered by: ${{ github.event_name }} |
| 56 | + - Auto-merge enabled |
| 57 | + branch: update-changelog-${{ github.run_id }} |
| 58 | + base: main |
| 59 | + delete-branch: true |
| 60 | + labels: documentation, automated-pr |
| 61 | + |
| 62 | + - name: Enable Auto-merge |
| 63 | + if: steps.generate.outputs.changes == 'true' |
| 64 | + run: | |
| 65 | + gh pr merge --auto --merge "${{ steps.create-pr.outputs.pull-request-number }}" |
| 66 | + env: |
| 67 | + GH_TOKEN: ${{ secrets.CHANGELOG_TOKEN }} |
0 commit comments