Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add deploy key to SSH agent forwarding for Docker build in Google Cloud Build
- name: 'gcr.io/cloud-builders/git'
secretEnv: ['SSH_KEY']
entrypoint: 'bash'
args:
- -c
- |
echo "$$SSH_KEY" >> /root/.ssh/id_rsa
chmod 400 /root/.ssh/id_rsa
volumes:
- name: 'ssh'
path: /root/.ssh
- name: "gcr.io/cloud-builders/docker"
args:
[
"build",
"--ssh",
"default=/root/.ssh/id_rsa",
".",
]
env:
- "DOCKER_BUILDKIT=1"
volumes:
- name: 'ssh'
path: /root/.ssh
availableSecrets:
secretManager:
- versionName: projects/$PROJECT_ID/secrets/machineuser-ssh-key/versions/latest
env: 'SSH_KEY'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment