skip to Main Content

I have a reusable workflow that I have created in Github Actions, it uses AWS CodeBuild as a runner i.e.

jobs:
  docker:
    runs-on: codebuild-XXX-XXX-${{ github.run_id }}-${{ github.run_attempt }}

The workflow runs fine on CodeBuild when I invoke it using workflow dispatch, but when I call it from another repository it hangs with waiting for runner...

I have tried to add a webhook to the codebuild job for the calling repository, and added a GITHUB_TOKEN to the reusable workflow.

Not sure where to go next to debug / what could be causing this.

Thanks in advance

2

Answers


  1. In this case, if you aren’t seeing any builds triggered within the project as a result of the webhook request, I’m guessing that the webhook request got rejected by CodeBuild. To debug, you can follow the steps at https://docs.aws.amazon.com/codebuild/latest/userguide/action-runner.html:

    1. Open https://github.com/<user-name>/<repository-name>/settings/hooks in the GitHub console
    2. Click the Recent Deliveries tab and look for a workflow_job.queued event
    3. Check the request’s response to see if it got rejected. If it did, there will likely be some information regarding why the request was rejected
    Login or Signup to reply.
  2. "I have tried to add a webhook to the codebuild job for the calling repository"

    From the description, it seems your setup looks like this:

    • Repo 1 (hosting the reusable workflow) -> webhook 1 -> CodeBuild project(project name: "XXX-XXX")

    • Repo 2 (hosting a workflow that calls the workflow in Repo 1) -> webhook 2 -> CodeBuild Project (project name: "YYY-YYY")

    If that is the case, workflow job requests from Repo 2 will be sent to project YYY-YYY and get rejected, with an exception message "Cannot resolve label or label did not match webhook project name: codebuild-XXX-XXX".

    The key issue is the mismatched project name and I can think of two solutions.

    1. Set the project-name in the label dynamically. For example, make the project_name as an input. There are some other ways to achieving this, see https://github.com/search?q=%22+codebuild-%24%7B%7B%22&type=code
    on:
      workflow_call:
        inputs:
          project_name:
            description: 'CodeBuild Project name'
            default: 'XXX-XXX'
    
    jobs:
      docker:
        runs-on: codebuild-${{ input.project_name }}-${{ github.run_id }}-${{ github.run_attempt }}
    
    
    1. If these two repositories belong to the same organization, you can use organizational webhook to use just 1 webhook and 1 CodeBuild project to process both workflows.
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search