Skip to content

Instantly share code, notes, and snippets.

@automaticalldramatic
Last active September 6, 2019 12:32
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 automaticalldramatic/961dbd2a92a6b9518835688eb2df2d67 to your computer and use it in GitHub Desktop.
Save automaticalldramatic/961dbd2a92a6b9518835688eb2df2d67 to your computer and use it in GitHub Desktop.
A cloudbuild that works for me with private packages
env: flex
runtime: go1.12
main: cmd/some-service-name/main.go
substitutions:
_APP: github.com/automaticalldramatic/some-app-name
options:
volumes:
- name: 'ssh'
path: /root/.ssh
steps:
- id: decrypt keys
name: 'gcr.io/cloud-builders/gcloud'
args:
- kms
- decrypt
- --ciphertext-file=gcp_id_rsa.enc
- --plaintext-file=/root/.ssh/id_rsa
- --location=global
- --keyring=automaticalldramatic-keyring
- --key=github-key
# Set up git with key and domain.
- id: setup ssh
name: 'gcr.io/cloud-builders/git'
entrypoint: 'bash'
args:
- '-c'
- |
chmod 600 /root/.ssh/id_rsa
cat <<EOF >/root/.ssh/config
Hostname github.com
IdentityFile /root/.ssh/id_rsa
EOF
mv known_hosts /root/.ssh/known_hosts
ls -al /workspace
- name: 'gcr.io/cloud-builders/git'
entrypoint: 'git'
args:
- config
- --global
- --add
- url.git@github.com:.insteadOf
- https://github.com/
- name: mirror.gcr.io/library/golang
args:
- go
- get
- "google.golang.org/appengine"
env:
- GO111MODULE=on
- GOPATH=/go
- PROJECT_ROOT="/go/src/${_APP}"
volumes:
- name: go-modules
path: /go
# Build the module.
- id: build the module
name: mirror.gcr.io/library/golang
args: ['go', 'get', '-u', './...']
env:
- GO111MODULE=on
- GOPATH=/go
- PROJECT_ROOT="/go/src/${_APP}"
volumes:
- name: go-modules
path: /go
# Copy the pkg/mod to /src
- id: copy go pkg mods
name: mirror.gcr.io/library/golang
entrypoint: 'bash'
args:
- '-c'
- |
cp -R /go/pkg/mod/* /go/src/
volumes:
- name: go-modules
path: /go
- id: deploy app
name: 'gcr.io/cloud-builders/gcloud'
args:
- app
- deploy
# dir: "/go/src/${_APP}"
env:
- GO111MODULE=on
- GOPATH=/go
- PROJECT_ROOT="/go/src/${_APP}"
# volumes:
# - name: go-modules
# path: /go
@automaticalldramatic
Copy link
Author

service
  |
  |__cmd
  |  |_main.go
  |
  |_ app.yaml
  |_ cloudbuild.yaml
  |_ service.go
  |_ someHelper.go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment