Last active
September 6, 2019 12:32
-
-
Save automaticalldramatic/961dbd2a92a6b9518835688eb2df2d67 to your computer and use it in GitHub Desktop.
A cloudbuild that works for me with private packages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
env: flex | |
runtime: go1.12 | |
main: cmd/some-service-name/main.go |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
- [email protected]:.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 |
Author
automaticalldramatic
commented
Sep 6, 2019
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment