Commit same changes on multiple branches #221
-
Hi! I was trying to figure out if it was possible to commit the same changes that happened in the workflow to multiple branches, my use case is pretty simple: I have a workflow that builds and updates the Right now my action does something like this: - name: Bump build and tag on master
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: master
commit_message: "chore: bumped build numbers"
commit_options: "--no-verify"
tagging_message: "v${{steps.version.outputs.prop}}" However, if I try to update both branches in sequence i get no commit from the second one (because there are no changes to commit, they were already committed on master!) - name: Bump build and tag on master
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: master
commit_message: "chore: bumped build numbers"
commit_options: "--no-verify"
tagging_message: "v${{steps.version.outputs.prop}}"
- name: Bump build and tag on production
uses: stefanzweifel/git-auto-commit-action@v4
with:
branch: production
commit_message: "chore: bumped build numbers"
commit_options: "--no-verify"
tagging_message: "v${{steps.version.outputs.prop}}" Is there a git setting I'm not aware of I need to toggle to achieve this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
There is no secret setting in
The workflow for solution 2 would look something like this. (Haven't tested this on GitHub Actions, but should work as it's just a chain of basic git commands) - name: Bump build and tag on master
uses: stefanzweifel/git-auto-commit-action@v4
+ id: auto_commit
with:
branch: master
commit_message: "chore: bumped build numbers"
commit_options: "--no-verify"
tagging_message: "v${{steps.version.outputs.prop}}"
-- name: Bump build and tag on production
- uses: stefanzweifel/git-auto-commit-action@v4
- with:
- branch: production
- commit_message: "chore: bumped build numbers"
- commit_options: "--no-verify"
- tagging_message: "v${{steps.version.outputs.prop}}"
+ - name: Bump build and tag on production
+ run:
+ git fetch origin
+ git checkout -b production origin/production
+ git cherry-pick ${{ steps.auto_commit.outputs.commit_hash }}
+ git tag -a "v${{steps.version.outputs.prop}}" ${{ steps.auto_commit.outputs.commit_hash }}
+ git push --follow-tags --atomic --set-upstream origin production A couple of problems you might run into:
|
Beta Was this translation helpful? Give feedback.
There is no secret setting in
git-auto-commit
to make this workflow possible. But I see 2 ways to solve your problem:buildNumber
. One job pushes the changes tomaster
the other toproduction
.git-auto-commit-action
twice, the second step cherry picks the commit from one branch to the other.The workflow for solution 2 would look something like this. (Haven't tested this on GitHub Actions, but should work as it's just a chain of basic git commands)
- name: Bump build and tag on master uses: stefanzweifel/git-auto-commit-action@v4 + id: auto_commit with: branch: master …