Configuring actions to depend on other actions
By default, when you add actions to a workflow, they are added side by side in the
visual editor. This means that the actions
will run in parallel when you start a workflow run. If you want actions to run in
sequential order (and appear vertically in the visual editor), you must set up
dependencies between them. For example, you might set up a Test
action to
depend on the Build
action so that the test action runs after the build
action.
You can set up dependencies between actions, between action groups, and between actions and action groups. You can also configure one-to-many dependencies so that one action depends on several others in order to start. Consult the Guidelines for setting up dependencies to ensure your dependency setup conforms with the workflow's YAML syntax.
Setting up dependencies
Use the following instructions to set up dependencies between actions in a workflow.
Guidelines for setting up dependencies
When configuring dependencies, follow these guidelines:
-
If an action is inside an action group, that action can only depend on other actions within the same action group.
-
Actions and action groups can depend on other actions and action groups at the same level in the YAML hierarchy, but not at a different level.
Examples
The following examples show how to configure dependencies between actions and action groups in the workflow definition file.
Topics
Example: Configuring a simple dependency
The following example shows how to configure a Test
action to
depend on the Build
action using the DependsOn
property.
Actions:
Build:
Identifier: aws/build@v1
Configuration:
...
Test:
DependsOn:
- Build
Identifier: aws/managed-test@v1
Configuration:
...
Example: Configuring an action group to depend on an action
The following example shows how to configure a DeployGroup
action
group to depend on the FirstAction
action. Notice that action and
action group are at the same level.
Actions:
FirstAction: #An action outside an action group
Identifier: aws/github-actions-runner@v1
Configuration:
...
DeployGroup: #An action group containing two actions
DependsOn:
- FirstAction
Actions:
DeployAction1:
...
DeployAction2:
...
Example: Configuring an action group to depend on another action group
The following example shows how to configure a DeployGroup
action
group to depend on the BuildAndTestGroup
action group. Notice that
the action groups are at the same level.
Actions:
BuildAndTestGroup: # Action group 1
Actions:
BuildAction:
...
TestAction:
...
DeployGroup: #Action group 2
DependsOn:
- BuildAndTestGroup
Actions:
DeployAction1:
...
DeployAction2:
...
Example: Configuring an action group to depend on multiple actions
The following example shows how to configure a DeployGroup
action
group to depend on the FirstAction
action, the
SecondAction
action, as well as the
BuildAndTestGroup
action group. Notice that
DeployGroup
is at the same level as FirstAction
,
SecondAction
, and BuildAndTestGroup
.
Actions:
FirstAction: #An action outside an action group
...
SecondAction: #Another action
...
BuildAndTestGroup: #Action group 1
Actions:
Build:
...
Test:
...
DeployGroup: #Action group 2
DependsOn:
- FirstAction
- SecondAction
- BuildAndTestGroup
Actions:
DeployAction1:
...
DeployAction2:
...