Usage guidelines for triggers and branches
This section describes some of the main guidelines when setting up Amazon CodeCatalyst triggers that include branches.
For more information about triggers, see Starting a workflow run automatically using triggers.
-
Guideline 1: For both push and pull request triggers, if you are going to specify a branch, you must specify the destination (or 'to') branch in the trigger configuration. Never specify the source (or 'from') branch.
In the following example, a push from any branch to
main
activates the workflow.Triggers: - Type: PUSH Branches: - main
In the following example, a pull request from any branch into
main
activates the workflow.Triggers: - Type: PULLREQUEST Branches: - main Events: - OPEN - REVISION
-
Guideline 2: For push triggers, after the workflow is activated, the workflow will run using the workflow definition file and source files in the destination branch.
-
Guideline 3: For pull request triggers, after the workflow is activated, the workflow will run using the workflow definition file and source files in the source branch (even though you specified the destination branch in the trigger configuration).
-
Guideline 4: The exact same trigger in one branch might not run in another branch.
Consider the following push trigger:
Triggers: - Type: PUSH Branches: - main
If the workflow definition file containing this trigger exists in
main
and gets cloned totest
, the workflow will never start automatically using the files intest
(although you could start the workflow manually to have it use the files intest
). Review Guideline 2 to understand why the workflow will never run automatically using the files intest
.Consider also the following pull request trigger:
Triggers: - Type: PULLREQUEST Branches: - main Events: - OPEN - REVISION
If the workflow definition file containing this trigger exists in
main
, the workflow will never run using the files inmain
. (However, if you create atest
branch off ofmain
, the workflow will run using the files intest
.) Review Guideline 3 to understand why.