Search code examples
githubgithub-actions

I’m trying to push to master after I run a github action


When I run my action I have a program that changes a file and I want to have it automatically push to the github after it runs. Is there a way I can do that?


Solution

  • The Github Actions Runner have git pre-installed. You can simply execute all standard Git console commands directly. Of course, you still have to make sure to configure the name and e-mail that should be displayed for the commits. It's a good idea to just use the Github Actions bot for this. So you can simply add a step to your workflow that looks something like this:

          - name: Push
            run: |
              git config --global user.name github-actions
              git config --global user.email 41898282+github-actions[bot]@users.noreply.github.com
              git add .
              git commit -m '[Automated action] Build'
              git push