

Amazon CodeCatalyst is no longer open to new customers. Existing customers can continue to use the service as normal. For more information, see [How to migrate from CodeCatalyst](migration.md).

# Connecting source repositories to workflows
<a name="workflows-sources"></a>

A *source*, also called an *input source*, is a source repository to which a [workflow action](workflows-actions.md) connects in order to obtain the files it needs to carry out its operations. For example, a workflow action might connect to a source repository to obtain application source files in order to build an application.

CodeCatalyst workflows support the following sources:
+ CodeCatalyst source repositories – For more information, see [Store and collaborate on code with source repositories in CodeCatalystStore and collaborate on code with source repositories](source.md).
+ GitHub repositories, Bitbucket repositories, and GitLab project repositories – For more information, see [Add functionality to projects with extensions in CodeCatalystAdd functionality to projects with extensions](extensions.md).

**Topics**
+ [

# Specifying a workflow file's source repository
](workflows-sources-specify-workflow-def.md)
+ [

# Specifying a workflow action's source repository
](workflows-sources-specify-action.md)
+ [

# Referencing source repository files
](workflows-sources-reference-files.md)
+ [

# 'BranchName' and 'CommitId' variables
](workflows-sources-variables.md)

# Specifying a workflow file's source repository
<a name="workflows-sources-specify-workflow-def"></a>

Use the following instructions to specify the CodeCatalyst source repository where you want to store your workflow definition file. If you'd rather specify a GitHub repository, Bitbucket repository, or GitLab project repository, see instead [Add functionality to projects with extensions in CodeCatalystAdd functionality to projects with extensions](extensions.md).

The source repository where your workflow definition file resides is identified by the label, `WorkflowSource`.

**Note**  
You specify the source repository where your workflow definition file resides when you first commit your workflow definition file. After this commit, the repository and workflow definition file are linked together permanently. The only way to change the repository after the initial commit is to re-create the workflow in a different repository.

**To specify the source repository that will store the workflow definition file**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. Choose your project.

1. In the navigation pane, choose **CI/CD**, and then choose **Workflows**.

1. Choose **Create workflow** and create the workflow. For more information, see [Creating a workflow](workflows-create-workflow.md).

   During the workflow creation process, you can specify the CodeCatalyst repository, branch, and folder where you want to store your workflow definition file.

# Specifying a workflow action's source repository
<a name="workflows-sources-specify-action"></a>

Use the following instructions to specify a source repository to use with a workflow action. On startup, the action bundles the files at the configured source repository into an artifact, downloads the artifact to the [runtime environment Docker image](build-images.md) where the action is running, and then completes its processing using the downloaded files.

**Note**  
Currently, within a workflow action, you can only specify one source repository, which is the source repository where the workflow definition file resides (in the `.codecatalyst/workflows/` directory or one of its subdirectories). This source repository is represented by the label `WorkflowSource`.

------
#### [ Visual ]

**To specify the source repository that an action will use (visual editor)**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. Choose your project.

1. In the navigation pane, choose **CI/CD**, and then choose **Workflows**.

1. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name or status.

1. Choose **Edit**.

1. Choose **Visual**.

1. In the workflow diagram, choose the action where you want to specify the source.

1. Choose **Inputs**.

1. In **Sources - optional** do the following:

   Specify the labels that represent the source repositories that will be needed by the action. Currently, the only supported label is `WorkflowSource`, which represents the source repository where your workflow definition file is stored.

   If you omit a source, then you must specify at least one input artifact under `action-name/Inputs/Artifacts`.

   For more information about sources, see [Connecting source repositories to workflows](workflows-sources.md).

1. (Optional) Choose **Validate** to validate the workflow's YAML code before committing.

1. Choose **Commit**, enter a commit message, and choose **Commit** again.

------
#### [ YAML ]

**To specify the source repository that an action will use (YAML editor)**

1. Open the CodeCatalyst console at [https://codecatalyst.aws/](https://codecatalyst.aws/).

1. Choose your project.

1. In the navigation pane, choose **CI/CD**, and then choose **Workflows**.

1. Choose the name of your workflow. You can filter by the source repository or branch name where the workflow is defined, or filter by workflow name or status.

1. Choose **Edit**.

1. Choose **YAML**.

1. In an action, add code similar to the following:

   ```
   action-name:
    Inputs:
      Sources:
        - WorkflowSource
   ```

   For more information, see the description of the `Sources` property in [Workflow YAML definition](workflow-reference.md) for your action.

1. (Optional) Choose **Validate** to validate the workflow's YAML code before committing.

1. Choose **Commit**, enter a commit message, and choose **Commit** again.

------

# Referencing source repository files
<a name="workflows-sources-reference-files"></a>

If you have files that reside in a source repository, and you need to refer to these files in one of your workflow actions, complete the following procedure.

**Note**  
See also [Referencing files in an artifact](workflows-working-artifacts-refer-files.md).

**To reference a file stored in a source repository**
+ In the action where you want to reference a file, add code similar to the following:

  ```
  Actions:
    My-action:
      Inputs:
        Sources:
          - WorkflowSource
        Configuration:
          Steps:
          - run: cd my-app && cat file1.jar
  ```

  In the previous code, the action looks in the `my-app` directory in the root of the `WorkflowSource` source repository to find and display the `file1.jar` file.

# 'BranchName' and 'CommitId' variables
<a name="workflows-sources-variables"></a>

The CodeCatalyst source produces and sets `BranchName` and `CommitId` variables when your workflow runs. These are known as *predefined variables*. See the following table for information about these variables.

For information about referencing these variables in a workflow, see [Using predefined variables](workflows-using-predefined-variables.md).


| Key | Value | 
| --- | --- | 
|  CommitId  |  The commit ID representing the state of the repository at the time the workflow run started. Example: `example3819261db00a3ab59468c8b` See also: [Example: Referencing the "CommitId" predefined variable](workflows-predefined-examples.md#workflows-working-with-variables-ex-refer-action)  | 
|  BranchName  |  The name of the branch against which the workflow run started. Examples: `main`, `feature/branch`, `test-LiJuan` See also: [Example: Referencing the "BranchName" predefined variable](workflows-predefined-examples.md#workflows-working-with-variables-ex-branch)  | 