diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml index fe61a961..aa4cd89b 100644 --- a/.github/workflows/changelog.yml +++ b/.github/workflows/changelog.yml @@ -1,33 +1,33 @@ -name: Generate changelog - -on: workflow_dispatch +on: + push: + tags: + - 'v*' jobs: - generate-changelog: + changelog: name: Generate changelog - runs-on: ubuntu-20.04 - outputs: - release_body: ${{ steps.release.outputs.release_body }} + runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v2 with: + repository: ${{ github.event.pull_request.head.repo.full_name }} + ref: ${{ github.event.pull_request.head.ref }} fetch-depth: 0 + - name: Generate a changelog uses: orhun/git-cliff-action@v1 id: git-cliff with: config: cliff.toml - args: --output CHANGELOG.md + args: --verbose env: OUTPUT: CHANGELOG.md - - name: Set the release body - id: release - shell: bash - run: | - r=$(cat ${{ steps.git-cliff.outputs.changelog }}) - r="$(printf "$r" | tail -n +3)" - r="${r//'%'/'%25'}" - r="${r//$'\n'/'%0A'}" - r="${r//$'\r'/'%0D'}" - echo "::set-output name=release_body::$r" + + - name: Commit the changelog + uses: EndBug/add-and-commit@v9 + with: + add: 'CHANGELOG.md' + author_name: Git Cliff + committer_name: Git Cliff + message: 'chore: update CHANGELOG.md'