R/buildstep_templates_git.R
cr_buildstep_git.Rd
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()
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 |
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
Accessing private GitHub repositories using Cloud Build (google article)
Other Cloud Buildsteps:
cr_buildstep_bash()
,
cr_buildstep_decrypt()
,
cr_buildstep_df()
,
cr_buildstep_docker()
,
cr_buildstep_edit()
,
cr_buildstep_extract()
,
cr_buildstep_gcloud()
,
cr_buildstep_mailgun()
,
cr_buildstep_nginx_setup()
,
cr_buildstep_pkgdown()
,
cr_buildstep_run()
,
cr_buildstep_r()
,
cr_buildstep_secret()
,
cr_buildstep_slack()
,
cr_buildstep()
#>#> [1] "my-project"#> ℹ 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