iTranslated by AI
Troubleshooting GitHub Actions workflow_run: Check Your Branches
GitHub Actions has a feature called workflow_run that allows you to "trigger the execution of a workflow based on the start or completion of another workflow."
I tried to use this for the first time to set up my CI, but I got stuck because workflow_run wouldn't trigger midway through. Here is a note on why that happened.
TLDR
Events that trigger workflows - GitHub Docs
This event will only trigger a workflow run if the workflow file is on the default branch.
It seems that a workflow using on: workflow_run will not function unless the workflow file is pushed to the default branch.
In my case, I was working on a feature branch branched off from the default branch. Since I didn't know about this specification, I was scratching my head wondering why there was no response after pushing.
Let's test it by creating a sample repository
I created a verification repository on GitHub. I'll create the following workflows and push them to the default branch, main.
- Hello (hello.yml): A workflow that runs every time a push is made.
- World (world.yml): A workflow that runs every time "Hello" completes.
name: Hello
on: push
jobs:
hello:
runs-on: ubuntu-latest
steps:
- run: echo "Hello"
name: World
on:
workflow_run:
workflows:
- Hello
types:
- completed
jobs:
world:
runs-on: ubuntu-latest
steps:
- run: echo "World"
As a result,

As intended, "Hello" was executed, followed by the execution of "World."
Add more workflow files by branching off
Next, I'll create a branch called test from main and add the following japan.yml to it.
- Japan (japan.yml): A workflow that runs every time "Hello" completes.
It is basically the same as the "World" workflow, just with a different message to echo.
name: Japan
on:
workflow_run:
workflows:
- Hello
types:
- completed
jobs:
japan:
runs-on: ubuntu-latest
steps:
- run: echo "Japan"
The result of pushing to the test branch is shown below:

"Hello" and "World" worked, but "Japan" did not respond.
Try changing the default branch itself
Let's try to get "Japan" to work.
In a real project, it's common to merge test into main, but this time, I'll try changing the default branch from main to test.

After changing the default branch to test, triggering "Hello" by pushing once more results in:

All three workflows have been executed.
Discussion