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.

  1. 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

    Screenshot 2024-12-13 at 9.26.15 AM.png

    Click the create rule button

    Screenshot 2025-01-12 at 10.36.06 AM.png

    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.

  2. 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>

  3. 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>

    Screenshot 2024-12-13 at 9.33.33 AM.png

  4. You can then access the output in runs that depend on the above workflow by accessing the workflowInputs object:

    Screenshot 2024-12-13 at 9.35.56 AM.png

  5. When a workflow that has dependencies fails, all workflows that require that workflow will immediately fail.

    Screenshot 2024-12-13 at 9.38.26 AM.png

    There will also be a failure reason surfaced in the run result

    Screenshot 2024-12-13 at 9.38.18 AM.png