This creates steps to configure git to use an ssh created key.

This creates steps to use git with an ssh created key.

cr_buildstep_gitsetup(secret, post_setup = NULL)

cr_buildstep_git(
  git_args = c("clone", "git@github.com:[GIT-USERNAME]/[REPOSITORY]", "."),
  ...
)

git_volume()

Arguments

secret

The name of the secret on Google Secret Manager for the git ssh private key

post_setup

Steps that occur after git setup

git_args

The arguments to send to git

...

Further arguments passed in to cr_buildstep

Details

The ssh private key should be uploaded to Google Secret Manager first

cr_buildstep must come after cr_buildstep_gitsetup

Use git_volume to add the git credentials folder to other buildsteps

See also

Examples

cr_project_set("my-project")
#> 2021-03-19 12:27:04 > ProjectId set to my-project
#> [1] "my-project"
cr_bucket_set("my-bucket")
#> 2021-03-19 12:27:04 > Bucket set to my-bucket
#> [1] "my-bucket"
# assumes you have previously saved git ssh key called "github-ssh" cr_build_yaml( steps = c( cr_buildstep_gitsetup("github-ssh"), cr_buildstep_git(c("clone", "git@github.com:github_name/repo_name")) ) )
#> ==cloudRunnerYaml== #> steps: #> - name: gcr.io/cloud-builders/gcloud #> entrypoint: bash #> args: #> - -c #> - gcloud secrets versions access latest --secret=github-ssh > /root/.ssh/id_rsa #> id: git secret #> volumes: #> - name: ssh #> path: /root/.ssh #> - name: gcr.io/cloud-builders/git #> entrypoint: bash #> args: #> - -c #> - |- #> chmod 600 /root/.ssh/id_rsa #> cat <<EOF >known_hosts #> github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ== #> EOF #> cat <<EOF >/root/.ssh/config #> Hostname github.com #> IdentityFile /root/.ssh/id_rsa #> EOF #> mv known_hosts /root/.ssh/known_hosts #> git config --global user.name "googleCloudRunner" #> git config --global user.email "cr_buildstep_gitsetup@googleCloudRunner.com" #> id: git setup script #> volumes: #> - name: ssh #> path: /root/.ssh #> - name: gcr.io/cloud-builders/git #> args: #> - clone #> - git@github.com:github_name/repo_name #> volumes: #> - name: ssh #> path: /root/.ssh