Last active
June 25, 2020 13:38
-
-
Save nk-gears/e2b865e1a3eb9ee03e5ad05949b29e88 to your computer and use it in GitHub Desktop.
CloudBuild Automated Triggers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://codelabs.developers.google.com/codelabs/cloud-builder-gke-continuous-deploy/index.html#1 | |
cat <<EOF > branch-build-trigger.json | |
{ | |
"triggerTemplate": { | |
"projectId": "${PROJECT}", | |
"repoName": "default", | |
"branchName": "[^(?!.*master)].*" | |
}, | |
"description": "branch", | |
"substitutions": { | |
"_CLOUDSDK_COMPUTE_ZONE": "${ZONE}", | |
"_CLOUDSDK_CONTAINER_CLUSTER": "${CLUSTER}" | |
}, | |
"filename": "builder/cloudbuild-dev.yaml" | |
} | |
EOF | |
curl -X POST \ | |
https://cloudbuild.googleapis.com/v1/projects/${PROJECT}/triggers \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" \ | |
--data-binary @branch-build-trigger.json | |
cat <<EOF > master-build-trigger.json | |
{ | |
"triggerTemplate": { | |
"projectId": "${PROJECT}", | |
"repoName": "default", | |
"branchName": "master" | |
}, | |
"description": "master", | |
"substitutions": { | |
"_CLOUDSDK_COMPUTE_ZONE": "${ZONE}", | |
"_CLOUDSDK_CONTAINER_CLUSTER": "${CLUSTER}" | |
}, | |
"filename": "builder/cloudbuild-canary.yaml" | |
} | |
EOF | |
curl -X POST \ | |
https://cloudbuild.googleapis.com/v1/projects/${PROJECT}/triggers \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" \ | |
--data-binary @master-build-trigger.json | |
cat <<EOF > tag-build-trigger.json | |
{ | |
"triggerTemplate": { | |
"projectId": "${PROJECT}", | |
"repoName": "default", | |
"tagName": ".*" | |
}, | |
"description": "tag", | |
"substitutions": { | |
"_CLOUDSDK_COMPUTE_ZONE": "${ZONE}", | |
"_CLOUDSDK_CONTAINER_CLUSTER": "${CLUSTER}" | |
}, | |
"filename": "builder/cloudbuild-prod.yaml" | |
} | |
EOF | |
curl -X POST \ | |
https://cloudbuild.googleapis.com/v1/projects/${PROJECT}/triggers \ | |
-H "Content-Type: application/json" \ | |
-H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" \ | |
--data-binary @tag-build-trigger.json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment