Closed jacobolofsson closed 1 year ago
Yes, you have to set this action to not push. And then use this other action to create the pr: https://github.com/marketplace/actions/create-pull-request
I don't see any issues with this setup, it should work right away. Feel free to ask here if you need help.
I am having the same issue/doubt, I created a temporary branch and trying to push the commitizen diffs, but it isn't working.
- name: Create temporary branch
run: |
git checkout -b create-pull-request/patch main
git push origin create-pull-request/patch
- id: cz
name: Bump and Changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: body.md
I'm getting this error:
Pushing to branch...
error: cannot pull with rebase: You have unstaged changes.
error: please commit or stash them.
I think it's a different issue if you are trying to push from this action, but it doesn't. And for that you will have to share the whole action. I cannot see how you have configured the on
key. Or the checkout action.
And again, if what you want is this action not to push, you have to tell it not to push, which I don't see in the snippet, something like this:
- id: cz
name: Bump and Changelog
uses: commitizen-tools/commitizen-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
changelog_increment_filename: body.md
push: false
Thanks for the help! I was able to get something working with:
jobs:
bump_version:
runs-on: ubuntu-latest
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: cz
name: Create bump and changelog
uses: commitizen-tools/commitizen-action@0.16.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
push: false
- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
branch: bump-version-${{ steps.cz.outputs.version }}
title: Bump version ${{ steps.cz.outputs.version }}
which works to create the bump commit, and automatically open a PR. However, the tag is lost somewhere on the way I think. Do I need to enable some setting to also get the tag pushed to the PR as well?
The tag is there, you can probably add a step and do git tag
and it will be displayed.
For your next step I think you'll have to ask the maintainers of the action peter-evans/create-pull-request
.
I have never seen this behavior so I'm not sure we can help. If you are creating the PR under the same repository, then you can add a new step and just push the tag. If you are creating a PR from a fork... I'm not sure it's possible to make a PR with a tag in it.
I'm closing now, but feel free to continue in a discussion
If anyone else finds this issue and were wondering, this is what I ended up with in the end:
name: Bump version
on:
schedule:
- cron: "0 0 * * 0"
workflow_dispatch:
jobs:
bump_version:
runs-on: ubuntu-latest
name: "Bump version and create changelog with commitizen"
steps:
- name: Check out
uses: actions/checkout@v3
with:
fetch-depth: 0
- id: cz
name: Create bump and changelog
uses: commitizen-tools/commitizen-action@0.16.3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
push: false
- name: Print Version
run: echo "Bumped to version ${{ steps.cz.outputs.version }}"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
branch: bump-version-${{ steps.cz.outputs.version }}
title: Bump version ${{ steps.cz.outputs.version }}
# add tag manually, since the PR action does not push tags
- run: |
git push origin --tags
Thanks for a great action & tool!
I have a repo set up with strict branch protection rules (that always requires a PR to main). It would be great if there was some option to push to a new branch, and then automatically open a PR to the target branch. (I envision having a workflow that run on a cron-schedule and opens a version bump PR once a day if there are new commits on main)
Maybe this is out of scope for this tool, and/or can be achieved by combining some existing actions? I'm still kinda new to GH actions, so I might be missing some obvious solutions as well