Skip to content

Commit

Permalink
Update cloudbuild.yaml (#305)
Browse files Browse the repository at this point in the history
* Update cloudbuild.yaml

Use $_AR_REPO_NAME instead of $_REPO_NAME for variable substitution, as $_REPO_NAME is misleading. See b/363222262 for details.

* Update test.cloudbuild.yaml
  • Loading branch information
g-samroberts authored Oct 8, 2024
1 parent ea4e065 commit 3a86ec3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions golang-sample/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ steps:
# Docker Build
- name: 'gcr.io/cloud-builders/docker'
args: ['build', '-t',
'us-central1-docker.pkg.dev/$PROJECT_ID/$_REPO_NAME/myimage:$SHORT_SHA', '.']
'us-central1-docker.pkg.dev/$PROJECT_ID/$_AR_REPO_NAME/myimage:$SHORT_SHA', '.']
# [END cloudbuild_go_image_yaml]

# [START cloudbuild_go_push_yaml]
# Docker push to Google Artifact Registry
- name: 'gcr.io/cloud-builders/docker'
args: ['push', 'us-central1-docker.pkg.dev/$PROJECT_ID/$_REPO_NAME/myimage:$SHORT_SHA']
args: ['push', 'us-central1-docker.pkg.dev/$PROJECT_ID/$_AR_REPO_NAME/myimage:$SHORT_SHA']
# [END cloudbuild_go_push_yaml]

# [START cloudbuild_go_deploy_yaml]
# Deploy to Cloud Run
- name: 'gcr.io/cloud-builders/gcloud'
args: ['run', 'deploy', 'helloworld-${SHORT_SHA}',
'--image=us-central1-docker.pkg.dev/$PROJECT_ID/$_REPO_NAME/myimage:$SHORT_SHA',
'--image=us-central1-docker.pkg.dev/$PROJECT_ID/$_AR_REPO_NAME/myimage:$SHORT_SHA',
'--region', 'us-central1', '--platform', 'managed']
# [END cloudbuild_go_deploy_yaml]

Expand All @@ -55,5 +55,5 @@ artifacts:
# [END cloudbuild_go_logs_yaml]
# Store images in Google Artifact Registry
images:
- us-central1-docker.pkg.dev/$PROJECT_ID/$_REPO_NAME/myimage:$SHORT_SHA
- us-central1-docker.pkg.dev/$PROJECT_ID/$_AR_REPO_NAME/myimage:$SHORT_SHA
# [END cloudbuild_go_yaml]
4 changes: 2 additions & 2 deletions golang-sample/test.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ steps:
- '-c'
- |
gcloud builds submit --config cloudbuild.yaml \
--substitutions SHORT_SHA=${SHORT_SHA},_REPO_NAME=${_REPO_NAME},_BUCKET_NAME=${_BUCKET_NAME}
--substitutions SHORT_SHA=${SHORT_SHA},_AR_REPO_NAME=${_AR_REPO_NAME},_BUCKET_NAME=${_BUCKET_NAME}
- id: cleanup
name: gcr.io/google.com/cloudsdktool/cloud-sdk
Expand All @@ -16,5 +16,5 @@ steps:
- '-c'
- |
gsutil rm gs://${_BUCKET_NAME}/${SHORT_SHA}_test_log.xml
gcloud artifacts docker images delete us-central1-docker.pkg.dev/${PROJECT_ID}/${_REPO_NAME}/myimage:${SHORT_SHA}
gcloud artifacts docker images delete us-central1-docker.pkg.dev/${PROJECT_ID}/${_AR_REPO_NAME}/myimage:${SHORT_SHA}
gcloud run services delete helloworld-${SHORT_SHA} --region us-central1 --quiet

0 comments on commit 3a86ec3

Please sign in to comment.