Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion .github/workflows/pr-bump-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,27 @@ jobs:
esac
} > comment.md

# Look up an existing preview comment so the next step edits it in
# place instead of appending a new one on every run.
# `peter-evans/create-or-update-comment` does not search by body
# itself -- it only creates new comments, or updates a specific
# `comment-id`.
- name: Find existing preview comment
id: find-comment
uses: peter-evans/find-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
comment-author: "github-actions[bot]"
body-includes: "<!-- commitizen-bump-preview -->"

- name: Post or update PR comment
uses: peter-evans/create-or-update-comment@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
# When empty (no prior comment found) a new one is created;
# otherwise the existing comment is edited in place.
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: comment.md
body-includes: "<!-- commitizen-bump-preview -->"
edit-mode: replace
23 changes: 17 additions & 6 deletions docs/tutorials/github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,20 @@ jobs:
;;
esac
} > comment.md
- uses: peter-evans/create-or-update-comment@v4
- name: Find existing preview comment
id: find-comment
uses: peter-evans/find-comment@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.pull_request.number }}
body-path: comment.md
comment-author: "github-actions[bot]"
body-includes: "<!-- commitizen-bump-preview -->"
- uses: peter-evans/create-or-update-comment@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
comment-id: ${{ steps.find-comment.outputs.comment-id }}
issue-number: ${{ github.event.pull_request.number }}
body-path: comment.md
edit-mode: replace
```

Expand All @@ -235,10 +243,13 @@ jobs:
`update_changelog_on_bump` is set in your config, also the changelog
entries that would be produced). Exit code `21` (`NoneIncrementExit`)
is treated as "no eligible bump" rather than a failure.
- **Sticky comment**: The hidden HTML marker `<!-- commitizen-bump-preview -->`
lets [`peter-evans/create-or-update-comment`](https://github.com/peter-evans/create-or-update-comment)
find and replace the previous preview on every push, instead of leaving a
growing trail of comments.
- **Sticky comment**: [`peter-evans/find-comment`](https://github.com/peter-evans/find-comment)
looks up an existing comment by the hidden HTML marker
`<!-- commitizen-bump-preview -->` and bot author, then
[`peter-evans/create-or-update-comment`](https://github.com/peter-evans/create-or-update-comment)
edits it in place (or creates a new one on the first run when the
marker is not yet present), instead of leaving a growing trail of
comments.

[jinja]: https://github.com/commitizen-tools/commitizen/blob/master/commitizen/changelog.py

Expand Down
Loading