GitHub Cloud Build Integration with multiple cloudbuild.yamls in monorepo

前端 未结 3 2190
隐瞒了意图╮
隐瞒了意图╮ 2020-12-29 07:37

GitHub\'s Google Cloud Build integration does not detect a cloudbuild.yaml or Dockerfile if it is not in the root of the repository.

When

3条回答
  •  滥情空心
    2020-12-29 08:04

    You can do this by adding a cloudbuild.yaml in the root of your repository with a single gcr.io/cloud-builders/gcloud step. This step should:

    1. Traverse each subdirectory or use find to locate additional cloudbuild.yaml files.
    2. For each found cloudbuild.yaml, fork and submit a build by running gcloud builds submit.
    3. Wait for all the forked gcloud commands to complete.

    There's a good example of one way to do this in the root cloudbuild.yaml within the GoogleCloudPlatform/cloud-builders-community repo.

    If we strip out the non-essential parts, basically you have something like this:

    steps:
    - name: 'gcr.io/cloud-builders/gcloud'
      entrypoint: 'bash'
      args:
      - '-c'
      - |
        for d in */; do
          config="${d}cloudbuild.yaml"
          if [[ ! -f "${config}" ]]; then
            continue
          fi
    
          echo "Building $d ... "
          (
            gcloud builds submit $d --config=${config}
          ) &
        done
        wait
    

提交回复
热议问题