Pull request merged doesn't start workflow on pull_request closed event

A Pull Request, merged through gh pr merge did not start a workflow that was listening on pull_request with type closed.

It seems like the pull_request closed event was not registered or somehow did not start the workflow that is listening on this event.


I have a workflow that should be triggered on pull_request closed events:

name: Backport on pull_request[closed]
on:
  pull_request:
    types: [closed]
jobs:
  backport:
    name: Backport
    runs-on: ubuntu-latest
....

Another workflow can be run manually, which runs a shell script that creates and merges a pull request, and then cleans up the mess it created (delete the new branches and reverts the merge).

Merging the pull request, should then trigger the above mentioned workflow. However, this does not happen.

See:

Could it be that the time that the pull request is open is important for the closed event to be triggered? Because of the automation, the Create and the Merge happen practically immediately after each other. Or is there something else I’m missing?

It feels like a bug to me, because the pull request is clearly merged (and thus closed), so the pull_request closed event should’ve triggered the workflow.

Seems I did not read 📍 The GitHub Actions Guidepost well enough.

events triggered by the GITHUB_TOKEN will not create a new workflow run

Solution:

If you would like to trigger a workflow from a workflow run, you can trigger the event using a personal access token

Thanks for sharing your solution with the community @korthout !

1 Like