60

This question refers to this: https://github.com/features/actions

I have written a GitHub action to build my code and create a production bundle. I'd like to have that included into my repository by committing the changes to origin/master. This seems like an obvious feature for GitHub actions to have but I can't find it anywhere. How do I commit changes with a GitHub action and push them?

Ben Cooper
  • 1,288
  • 2
  • 10
  • 21
  • 3
    First of all, they're not duplicates. Mine discusses how to commit and push, not just push. Secondly, mine predates that question by about 4 months. – Ben Cooper Oct 05 '19 at 18:20

3 Answers3

40

Update: Please see the following question/answer for full details about how to push changes back to the remote. Push to origin from GitHub action

An alternative option is create-pull-request action. It will automatically commit changes to a new branch and raise a pull request for you to review the changes. I wrote a detailed explanation about it as an answer to another question here: https://stackoverflow.com/a/58004257/11934042

peterevans
  • 34,297
  • 7
  • 84
  • 83
15

I found the stefanzweifel/git-auto-commit-action to be the best solution. It's really as easy as:

- uses: stefanzweifel/git-auto-commit-action@v4

One could, of course, tune the parameters, like commit message, file globs and many others.

madhead
  • 31,729
  • 16
  • 153
  • 201
2

The easiest way to do this is to just integrate this action: https://github.com/cds-snc/github-actions/tree/master/auto-commit

It's a little frustrating because it has a default name/email that's ridiculous so you have to fork it to fix it but it otherwise works well.

Ben Cooper
  • 1,288
  • 2
  • 10
  • 21