From 8ba7c48da450f55712c682e8bf8181017a77f939 Mon Sep 17 00:00:00 2001 From: hoangdv2429 Date: Thu, 2 May 2024 14:54:45 +0700 Subject: [PATCH] guess I don't have a choice --- .github/workflows/changelog.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index 4ea807c..625491c 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -23,15 +23,28 @@ jobs: with: node-version: "18" - - name: Update Changelog + - name: Install conventional-changelog-cli + run: npm install -g conventional-changelog-cli + + - name: Simulate commit for PR title + run: | + # Format PR title as a conventional commit message + echo "${{ github.event.pull_request.title }}" > temp_message.txt + # Temporarily commit this message + git commit --allow-empty -F temp_message.txt + + - name: Generate changelog run: | - echo "### PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" >> CHANGELOG.md - echo "" >> CHANGELOG.md + conventional-changelog -p angular -i CHANGELOG.md -s -r 0 + cat CHANGELOG.md + + - name: Revert temporary commit + run: git reset HEAD~ - name: Commit and push changelog update run: | git config user.name 'github-actions' git config user.email 'github-actions@github.com' git add CHANGELOG.md - git commit -m "Update CHANGELOG.md with PR #${{ github.event.pull_request.number }} title" + git commit -m "Update CHANGELOG.md based on PR #${{ github.event.pull_request.number }} title" git push origin HEAD:refs/heads/${{ github.head_ref }}