Skip to content

Instantly share code, notes, and snippets.

@omegaes
Last active April 4, 2021 04:55
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 omegaes/e4f7fdfe081051f831cd57e29962c76a to your computer and use it in GitHub Desktop.
Save omegaes/e4f7fdfe081051f831cd57e29962c76a to your computer and use it in GitHub Desktop.
Create cloud build triggers and secrets
#!/bin/bash
# optain personal access token from Github to use for https clone
#https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token
printf "https://GIT_USERNAME:GITHUB_PERSONAL_TOKEN@github.com/GIT_ORGANAIZATION/ENVIRONMENT_REPO_NAME.git" | gcloud secrets create ENV_REPO_AUTH_URL --data-file=-
# For more details about cloud build and it's configration,
# please refer to https://cloud.google.com/build/docs/concepts
# if you use Github or BitBucket, you need to connect GCP project with your account
gcloud beta builds triggers create github \
--name="Demo-App-CI-CD-Master" \
--repo-name=GKE-Demo-App \
--repo-owner=XXXXX \
--branch-pattern=master \
--build-config=cloudbuild.yaml \
--substitutions _ENV_REPO_FILES="production/kustomization.yml",_ENV_REPO_MERGE_BRANCH="production/demo-app",_ENV_REPO_TARGET_BRANCH="master"
gcloud beta builds triggers create github \
--name="Demo-Env-CI-CD-Master" \
--repo-name=GKE-Demo-Environment \
--repo-owner=XXXXX \
--branch-pattern=master \
--build-config=cloudbuild.yaml
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment