From 3304b00aeb4efbe7ba4b429800eadaadfae6dade Mon Sep 17 00:00:00 2001 From: Callum Dunster Date: Tue, 24 Jun 2025 20:57:23 +0200 Subject: [PATCH] feat: add workflow for generating changelog preview as PR comment --- .../workflows/changelog-preview-comment.yml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/changelog-preview-comment.yml diff --git a/.github/workflows/changelog-preview-comment.yml b/.github/workflows/changelog-preview-comment.yml new file mode 100644 index 0000000..4b35165 --- /dev/null +++ b/.github/workflows/changelog-preview-comment.yml @@ -0,0 +1,47 @@ +name: Generate changelog preview + +on: + workflow_call: + inputs: + cliff_config_url: + type: string + description: URL to a git-cliff configuration file + default: https://raw.githubusercontent.com/holochain/release-integration/refs/heads/main/pre-1.0-cliff.toml + +jobs: + changelog-preview-comment: + runs-on: ubuntu-latest + + steps: + - name: Checkout PR commits only + uses: actions/checkout@v4 + with: + ref: ${{ github.event.pull_request.head.ref }} + fetch-depth: ${{ github.event.pull_request.commits }} + sparse-checkout: '' + sparse-checkout-cone-mode: false + + - name: Checkout all tags + run: git fetch --tags + + - name: Install git-cliff + uses: taiki-e/install-action@v2 + with: + tool: git-cliff@2.9.1 + + - name: Run git cliff + run: | + git cliff \ + --bump \ + --config-url="${{ inputs.cliff_config_url }}" \ + --strip=all \ + --output=PR_CHANGELOG.md + + - name: Add changelog preview as comment + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr comment ${{ github.event.pull_request.html_url }} \ + --body="$(printf 'The following will be added to the changelog\n\n---\n\n'; cat PR_CHANGELOG.md)" \ + --edit-last \ + --create-if-none