Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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