Avatar de Jeremy Herve

That’s me. And my blog. In English and in French.


How to: trigger a workflow from a workflow — GitHub Actions

If you work with GitHub Actions and have used actions to commit to a branch, you may have run into this little problem I ran into today: automatically generated commits and events triggered by a workflow, do not trigger any workflow.

In practice, that means that if you used a workflow to add a commit to your Pull Request, CI will not be triggered after that commit is pushed. All the events and CI that you would expect to see run on your Pull Request will not be triggered until your next push.

This is done on purpose by GitHub, as per the docs:

When you use the repository’s GITHUB_TOKEN to perform tasks, events triggered by the GITHUB_TOKEN, with the exception of workflow_dispatch and repository_dispatch, will not create a new workflow run. This prevents you from accidentally creating recursive workflow runs. For example, if a workflow run pushes code using the repository’s GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.

Automatic token authentication

A possible work-around in such cases is to use a personal access token instead of the default GITHUB_TOKEN to trigger events that require a token.

In my situation, I am using actions/github-script and its authenticated Octokit client. Specifically, I use createOrUpdateFileContents to add a new file, commit it, and push it to the branch. actions/github-script allows using the github-token input to pass your own custom token, so I used that:

uses: actions/github-script@v7
  with:
    github-token: ${{ secrets.API_TOKEN_GITHUB }}
    script: |

The generated commit now happens in my name, and CI events are triggered as expected by that commit.

Réactions sur le Fediverse

Continuez votre lecture / Keep reading

Discover more posts about or look at some of the posts suggested below.

Jeremy Herve
Jeremy Herve

WordPress, séries télé, enfants, et jeux de société. C’est sûrement la meilleure façon de me présenter en quelques mots. 🙂

Je travaille avec Automattic sur l’extension Jetpack et son infrastructure. Ne vous étonnez donc pas si je parle beaucoup de WordPress, ou du monde de l’open-source en général.

Je suis breton, donc je partage aussi des photos de notre jolie région de temps en temps ! 🙂

1 154 articles
101 abonnés