In this blog post I explain why GitHub actions don’t trigger each other by default, helping you how to achieve it.
Last week I wrote about how I configured a GitHub action to change this blog theme every day. Today I will explain you why I lost some time trying to understand why that action was not triggering my deploy to GitHub Pages action.
Before
Let's first do a side by side comparison on how each action is triggered:
name: publish
on:
push:
branches:
- master
Deploy is based on commits made to master
name: update-theme-color
on:
schedule:
- cron: "0 0 * * *"
Change blog theme color is based on a cron job
Intuitively you would think that once the update-theme-color
action runs, which creates a new commit in master, triggers the publish
action, since it reacts to master branch updates.
However...
That is not the case! By default GitHub Actions don't trigger each other to prevent recursive runs. For an action X
to be triggered by action Y
, then action X
needs to observe action Y
execution.
How
To observe actions execution, the workflow_run
reaction needs to be included. Here's how I reconfigured the publish
action:
name: publish
on:
push:
branches:
- master
workflow_run:
workflows: ["update-theme-color"]
types:
- completed
Top comments (0)