Skip to content

Instantly share code, notes, and snippets.

@Intelrunner
Created December 18, 2023 16:13
Show Gist options
  • Save Intelrunner/b547ba29fc25e43c1ade7545674b34ea to your computer and use it in GitHub Desktop.
Save Intelrunner/b547ba29fc25e43c1ade7545674b34ea to your computer and use it in GitHub Desktop.
Cloudbuild.yaml for Golang to pull from Artifact Registry (module) and build to CloudFunctions.
steps:
- name: golang
entrypoint: go
args: [ 'run', 'github.com/GoogleCloudPlatform/artifact-registry-go-tools/cmd/auth@v0.1.0', 'add-locations', '--locations=${_LOCATION}' ]
env:
# Set GOPROXY to the public proxy to pull the credential helper tool
- 'GOPROXY=proxy.golang.org'
- name: golang
entrypoint: go
args: [ 'run', 'github.com/GoogleCloudPlatform/artifact-registry-go-tools/cmd/auth@v0.1.0', 'refresh' ]
env:
- 'GOPROXY=proxy.golang.org'
- 'GONOPROXY=github.com/GoogleCloudPlatform/artifact-registry-go-tools'
# Add Vendor folder
- name: golang
entrypoint: go
args: [ 'mod', 'tidy' ]
env:
- 'GONOPROXY=github.com/GoogleCloudPlatform/artifact-registry-go-tools'
- 'GONOSUMDB=*.${_MODULE_PATH}'
- 'GOPRIVATE=*.${_MODULE_PATH}'
- name: golang
entrypoint: go
args: [ 'mod', 'vendor' ]
env:
- 'GONOPROXY=github.com/GoogleCloudPlatform/artifact-registry-go-tools'
- 'GONOSUMDB=*.${_MODULE_PATH}'
- 'GOPRIVATE=*.${_MODULE_PATH}'
- name: gcr.io/google.com/cloudsdktool/cloud-sdk
args:
- gcloud
- functions
- deploy
- hello-go
- --allow-unauthenticated
- --region=us-central1
- --source=.
- --trigger-http
- --runtime=go121
- --entry-point=HelloHTTP
- --set-build-env-vars=^;^GONOSUMDB="${_MODULE_PATH}";GOPRIVATE="${_MODULE_PATH}";GONOPROXY="github.com/GoogleCloudPlatform/artifact-registry-go-tools";GOPROXY="${_LOCATION}-go.pkg.dev/${_PROJECT_ID}/${_REPOSITORY},https://proxy.golang.org,direct"
options:
env: # Disable GO sumdb checks for private modules.
- 'GONOPROXY=github.com/GoogleCloudPlatform/artifact-registry-go-tools'
- 'GOPROXY=${_LOCATION}-go.pkg.dev/${_PROJECT_ID}/${_REPOSITORY},https://proxy.golang.org,direct'
- 'GONOSUMDB=${_MODULE_PATH}'
- 'GOPRIVATE=${_MODULE_PATH}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment