Workflow Run Rules allow you to sequence the order in which workflows run.
Take this scenario: I have a login workflow that I need an auth token
from to run before all of the other workflows on my team.
How do I accomplish this? Well, lets jump into it.
First you need to create a Rule for your team. Please be aware that all rules will apply to all runs on all branches.
<aside> ⚠️
Only create rules that the team as a whole needs
</aside>
Navigate to the bottom right corner when viewing a team and click on the Rules
button
Click the create rule
button
You will then be able to define which workflows should run before which. Please notice that you can also define this by the groups or tags that the workflows belong to. In the above rule, I have chosen to run all workflows that have the Auth
tag, before Dependent Test
and Failing Test
There is also a checkbox that says Fail workflows if any priors fail
this checkbox determines what should happen to dependent workflows when a prerequisite fails. If this checkbox is not checked, the dependent workflows will still run.
After defining your rules, you will sometimes need to access information from one of the workflows that needs to run first. This can be done by using the setOutput
function available in all Node 20 runners
<aside> ⚠️
Workflow Run Rules is not compatible with Classic Runners
</aside>
You can use the setOutput
function like so.
<aside> ⚠️
Note that the key used in the setOutput function must be unique. If you use the same key again it will overwrite the previous key value pair
</aside>
You can then access the output in runs that depend on the above workflow by accessing the workflowInputs
object:
When a workflow that has dependencies fails, all workflows that require that workflow will immediately fail.
There will also be a failure reason surfaced in the run result