Label overrides supported with the CodeBuild-hosted GitHub Actions runner - AWS CodeBuild

Label overrides supported with the CodeBuild-hosted GitHub Actions runner

In your GitHub Actions workflow YAML, you can provide a variety of label overrides that modify your self-hosted runner build. Any builds not recognized by CodeBuild will be ignored but will not fail your webhook request. For example, the following workflow YAML includes overrides for image, instance size, fleet, and the buildspec:

name: Hello World on: [push] jobs: Hello-World-Job: runs-on: - codebuild-myProject-${{ github.run_id }}-${{ github.run_attempt }} - image:${{ matrix.os }} - instance-size:${{ matrix.size }} - fleet:myFleet - buildspec-override:true strategy: matrix: include: - os: arm-3.0 size: small - os: linux-5.0 size: large steps: - run: echo "Hello World!"
Note

If your workflow job is hanging on GitHub, see and Using custom labels to route jobs.

codebuild-<project-name>-${{github.run_id}}-${{github.run_attempt}} (required)

  • Example: codebuild-fake-project-${{ github.run_id }}-${{ github.run_attempt }}

  • Required for all GitHub Actions workflow YAMLs. <project name> should be equal to the name of the project for which the self-hosted runner webhook is configured.

image:<environment-type>-<image-identifier>

instance-size:<instance-size>

fleet:<fleet-name>

buildspec-override:<boolean>

  • Example: buildspec-override:true

  • Allows the build to run buildspec commands in the INSTALL, PRE_BUILD, and POST_BUILD phases if set to true.

Single label override (legacy)

CodeBuild allows you to provide multiple overrides in a single label using the following:

  • To override your environment settings for an Amazon EC2/Lambda compute build, use the following syntax:

    runs-on: codebuild-<project-name>-${{ github.run_id }}-${{ github.run_attempt }}-<environment-type>-<image-identifier>-<instance-size>
  • To override your fleet settings for Amazon EC2 compute build, use the following syntax:

    runs-on: codebuild-<project-name>-${{ github.run_id }}-${{ github.run_attempt }}-fleet-<fleet-name>
  • To override both the fleet and the image used for the build, use the following syntax:

    runs-on: codebuild-<project-name>-${{ github.run_id }}-${{ github.run_attempt }}-image-<image-version>-fleet-<fleet-name>
  • To run buildspec commands during the build, -with-buildspec can be added as a suffix to the label:

    runs-on: codebuild-<project-name>-${{ github.run_id }}-${{ github.run_attempt }}-<image>-<image-version>-<instance-size>-with-buildspec
  • Optionally, you can provide an instance size override without overriding the image. For Amazon EC2 builds, you can exclude both environment type and image identifier. For Lambda builds, you can exclude the image identifier.