Skip to content

Instantly share code, notes, and snippets.

@tmaiaroto
Created August 10, 2019 05:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tmaiaroto/86322561c8fd0d33d009a8b34c712c24 to your computer and use it in GitHub Desktop.
Save tmaiaroto/86322561c8fd0d33d009a8b34c712c24 to your computer and use it in GitHub Desktop.
GCP Cloud Build - multiple builds from directories
# If a directory has a cb-deploy.yaml file, it will run for CD
steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
for d in */; do
config="${d}cb-deploy.yaml"
if [[ ! -f "${config}" ]]; then
continue
fi
echo "Building and deploying $d ... "
if [[ -z "${SHORT_SHA}" ]]
then
echo "==== $SHORT_SHA NOT FOUND - USING CLOUD BUILD LOCAL ===="
cloud-build-local --config=cb-deploy.yaml --dryrun=false --push $d
else
(
gcloud builds submit $d --config=${config}
) &
fi
done
wait
options:
substitution_option: 'ALLOW_LOOSE'
@tmaiaroto
Copy link
Author

tmaiaroto commented Aug 10, 2019

Unfortunately, without a custom builder, this won't work with Cloud Build Local because cloud-build-local requires Docker.... Docker in Docker.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment