Search code examples
github-actionsaws-codebuild

AWS CodeBuild as Github actions runner – change folder


I have a Github actions workflow that consists of two dependent jobs:

  1. Job A does change detection: Which modules in my monorepo changed.
  2. Job B is a matrix job, iterating of all changed modules (the working directories are the result of job a) and doing some CI stuff.

Now I want to use AWS CodeBuild to run as a self hosted runner for GitHub actions (so I can run everything in my VPC).

While this basically works, for each job, the code gets checked out to a different folder.

Job A return this folder for the target path to a changed module /codebuild/output/src1067370363/src/actions-runner/_work/myorg/myrepo/packages/module-a

But in Job B the source code ist checked out to /codebuild/output/src1107479956/src/actions-runner/_work/myorg/myrepo

Therefore all CI commands fail since the directory does not exist.

Is it possible in CodeBuild to change the directory?


Solution

  • The source path changes every build, but you can use the CODEBUILD_SRC_DIR environment variable to get the relative path. In self hosted runner builds, the value looks like /codebuild/output/src3071359377/src. You can check more detailed information on CodeBuild environment variables here.