Working with GitHub Actions output parameters - Amazon CodeCatalyst

Working with GitHub Actions output parameters

You can integrate GitHub output parameters into your CodeCatalyst workflows.

Note

Another word for output parameter is variable. Because GitHub uses the term output parameter in its documentation, we'll use this term too.

Exporting a GitHub output parameter so that other actions can use it

Use the following instructions to export a GitHub output parameter so that it is available for use in other CodeCatalyst workflow actions.

To export a GitHub output parameter
  1. Open a workflow and choose Edit. For instructions, see To edit a workflow.

  2. In the GitHub Actions action that generates the output parameter that you want to export, add an Outputs section with an underlying Variables property that looks like this:

    Actions: MyGitHubAction: Identifier: aws/github-actions-runner@v1 Outputs: Variables: - 'step-id_output-name'

    Replace:

    • step-id with value of the id: property in the GitHub action's steps section.

    • output-name with the name of the GitHub output parameter.

    Example

    The following example shows you how to export a GitHub output parameter called SELECTEDCOLOR.

    Actions: MyGitHubAction: Identifier: aws/github-actions-runner@v1 Outputs: Variables: - 'random-color-generator_SELECTEDCOLOR' Configuration: Steps: - name: Set selected color run: echo "SELECTEDCOLOR=green" >> $GITHUB_OUTPUT id: random-color-generator

Referencing a GitHub output parameter

Use the following instructions to reference a GitHub output parameter.

To reference a GitHub output parameter
  1. Complete the steps in Exporting a GitHub output parameter so that other actions can use it.

    The GitHub output parameter is now available for use in other actions.

  2. Note the output parameter's Variables value. It includes an underscore (_).

  3. Refer to the output parameter using the following syntax:

    ${action-name.output-name}

    Replace:

    • action-name with the name of the CodeCatalyst GitHub Action that produces the output parameter (do not use the GitHub action's name or id).

    • output-name with the output parameter's Variables value you noted earlier.

    Example

    BuildActionB: Identifier: aws/build@v1 Configuration: Steps: - Run: echo ${MyGitHubAction.random-color-generator_SELECTEDCOLOR}
    Example with context

    The following example shows you how to set a SELECTEDCOLOR variable in GitHubActionA, output it, and then refer to it in BuildActionB.

    Actions: GitHubActionA: Identifier: aws/github-actions-runner@v1 Configuration: Steps: - name: Set selected color run: echo "SELECTEDCOLOR=green" >> $GITHUB_OUTPUT id: random-color-generator Outputs: Variables: - 'random-color-generator_SELECTEDCOLOR' BuildActionB: Identifier: aws/build@v1 Configuration: Steps: - Run: echo ${GitHubActionA.random-color-generator_SELECTEDCOLOR}