Trigger Google Cloud Builds via GitHub App integration (#614)

Use cloudbuild.yaml for all invocations including via gcloud cli and github build triggers
This commit is contained in:
Deirdre Connolly 2020-07-09 14:22:56 -04:00 committed by GitHub
parent fcd2f43f39
commit e0a71c229d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 8 deletions

View File

@ -26,7 +26,7 @@ jobs:
BRANCH_NAME=${BRANCH_NAME,,} && \
echo "::set-env name=SHORT_BRANCH_NAME::$SHORT_BRANCH_NAME" && \
echo "::set-env name=BRANCH_NAME::$BRANCH_NAME" && \
echo "::set-env name=SHA7::$(git rev-parse --short=7 $GITHUB_SHA)"
echo "::set-env name=SHORT_SHA::$(git rev-parse --short=7 $GITHUB_SHA)"
# Setup gcloud CLI
- name: Set up gcloud Cloud SDK environment
@ -41,15 +41,14 @@ jobs:
# Tagging w/ the commit SHA blocks the :latest tag on GCR
run: |
gcloud builds submit \
--tag "gcr.io/$PROJECT_ID/$BRANCH_NAME:$SHA7" \
--machine-type n1-highcpu-32 \
--timeout 3600s \
--config cloudbuild.yaml \
--substitutions SHORT_SHA="$SHORT_SHA"
# Create instance template from container image
- name: Create instance template
run: |
gcloud compute instance-templates create-with-container "zebrad-$SHORT_BRANCH_NAME-$SHA7" \
--container-image "gcr.io/$PROJECT_ID/$BRANCH_NAME:$SHA7" \
gcloud compute instance-templates create-with-container "zebrad-$SHORT_BRANCH_NAME-$SHORT_SHA" \
--container-image "gcr.io/$PROJECT_ID/$BRANCH_NAME:$SHORT_SHA" \
--machine-type n1-highmem-8 \
--service-account cos-vm@zealous-zebra.iam.gserviceaccount.com \
--scopes cloud-platform \
@ -86,7 +85,7 @@ jobs:
run: |
gcloud compute instance-groups managed create \
"zebrad-$SHORT_BRANCH_NAME" \
--template "zebrad-$SHORT_BRANCH_NAME-$SHA7" \
--template "zebrad-$SHORT_BRANCH_NAME-$SHORT_SHA" \
--health-check zebrad-tracing-filter \
--initial-delay 30 \
--region us-central1 \
@ -98,5 +97,5 @@ jobs:
run: |
gcloud compute instance-groups managed rolling-action start-update \
"zebrad-$SHORT_BRANCH_NAME" \
--version template="zebrad-$SHORT_BRANCH_NAME-$SHA7" \
--version template="zebrad-$SHORT_BRANCH_NAME-$SHORT_SHA" \
--region us-central1 \

8
cloudbuild.yaml Normal file
View File

@ -0,0 +1,8 @@
steps:
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t', 'gcr.io/$PROJECT_ID/zcashfoundation/$REPO_NAME/$BRANCH_NAME:$SHORT_SHA', '.']
options:
machineType: 'N1_HIGHCPU_32'
timeout: 1800s # 30 mins