-
-
Notifications
You must be signed in to change notification settings - Fork 342
ci: add PR bump preview workflow #1957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
bearomorphism
merged 2 commits into
commitizen-tools:master
from
bearomorphism:feat/pr-bump-preview
May 19, 2026
+215
β0
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| name: PR bump preview | ||
|
|
||
| on: | ||
| pull_request_target: | ||
| types: [opened, reopened, synchronize, ready_for_review] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| bump-preview: | ||
| # Skip drafts, and skip fork PRs entirely. `pull_request_target` runs with | ||
| # the base repo's GITHUB_TOKEN (write access to PR comments). `cz bump` | ||
| # can render Jinja templates from the checked-out workspace whenever | ||
| # `update_changelog_on_bump` is set in config, and the renderer is not | ||
| # sandboxed (FileSystemLoader('.')) β running it against fork-controlled | ||
| # files would risk RCE / token exfiltration. Same-repo PRs are written by | ||
| # collaborators who already have push access, so the same risk doesn't | ||
| # apply. | ||
| if: > | ||
| ${{ | ||
| github.event.pull_request.draft == false && | ||
| github.event.pull_request.head.repo.full_name == | ||
| github.event.pull_request.base.repo.full_name | ||
| }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out PR head | ||
| uses: actions/checkout@v6 | ||
| with: | ||
| ref: ${{ github.event.pull_request.head.sha }} | ||
| fetch-depth: 0 | ||
| fetch-tags: true | ||
| # Defense in depth: don't write the workflow token to .git/config. | ||
| persist-credentials: false | ||
|
|
||
| - name: Set up Commitizen | ||
| uses: commitizen-tools/setup-cz@main | ||
| with: | ||
| set-git-config: false | ||
|
|
||
| - name: Run cz bump --dry-run | ||
| id: dry-run | ||
| run: | | ||
| set +e | ||
| output="$(cz bump --dry-run --yes 2>&1)" | ||
| status=$? | ||
| set -e | ||
| { | ||
| echo "status=${status}" | ||
| echo "output<<__CZ_BUMP_PREVIEW__" | ||
| printf '%s\n' "${output}" | ||
| echo "__CZ_BUMP_PREVIEW__" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Build comment body | ||
| env: | ||
| STATUS: ${{ steps.dry-run.outputs.status }} | ||
| OUTPUT: ${{ steps.dry-run.outputs.output }} | ||
| run: | | ||
| { | ||
| echo "<!-- commitizen-bump-preview -->" | ||
| echo "## π Commitizen bump preview" | ||
| echo "" | ||
| case "${STATUS}" in | ||
| 0) | ||
| echo "Merging this PR will produce the following bump:" | ||
| echo "" | ||
| echo '```' | ||
| printf '%s\n' "${OUTPUT}" | ||
| echo '```' | ||
| ;; | ||
| 21) | ||
| echo "No commits in this PR are eligible for a version bump." | ||
| ;; | ||
| *) | ||
| echo "β οΈ \`cz bump --dry-run\` exited with status \`${STATUS}\`:" | ||
| echo "" | ||
| echo '```' | ||
| printf '%s\n' "${OUTPUT}" | ||
| echo '```' | ||
| ;; | ||
| esac | ||
| } > comment.md | ||
|
|
||
| - name: Post or update PR comment | ||
| uses: peter-evans/create-or-update-comment@v4 | ||
| with: | ||
| token: ${{ secrets.GITHUB_TOKEN }} | ||
| issue-number: ${{ github.event.pull_request.number }} | ||
| body-path: comment.md | ||
| body-includes: "<!-- commitizen-bump-preview -->" | ||
| edit-mode: replace | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.