R/buildsteps_templates.R
cr_buildstep_pkgdown.Rd
Create buildsteps for deploying an R pkgdown website to GitHub
cr_buildstep_pkgdown(
github_repo,
git_email,
secret,
env = NULL,
build_image = "gcr.io/gcer-public/packagetools:latest",
post_setup = NULL,
post_clone = NULL
)
The GitHub repo to deploy pkgdown website from and to.
The email the git commands will be identifying as
The name of the secret on Google Secret Manager for the git ssh private key
A character vector of env arguments to set for all steps
A docker image with pkgdown
installed
Steps that occur after git setup
A cr_buildstep that occurs after the repo is cloned
Its convenient to set some of the above via Build macros, such as github_repo=$_GITHUB_REPO
and git_email=$_BUILD_EMAIL
in the Build Trigger web UI
To commit the website to git, cr_buildstep_gitsetup is used for which you will need to add your git ssh private key to Google Secret Manager
The R package is installed via install before running build_site
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_gitsetup()
,
cr_buildstep_mailgun()
,
cr_buildstep_nginx_setup()
,
cr_buildstep_packagetests()
,
cr_buildstep_run()
,
cr_buildstep_r()
,
cr_buildstep_secret()
,
cr_buildstep_slack()
,
cr_buildstep_targets()
,
cr_buildstep()
cr_project_set("my-project")
#> ℹ 2022-03-26 19:55:52 > ProjectId set to my-project
#> [1] "my-project"
cr_bucket_set("my-bucket")
#> ℹ 2022-03-26 19:55:52 > Bucket set to my-bucket
#> [1] "my-bucket"
# set github repo directly to write it out via cr_build_write()
cr_buildstep_pkgdown("MarkEdmondson1234/googleCloudRunner",
git_email = "cloudbuild@google.com",
secret = "github-ssh"
)
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/gcloud
#> entrypoint: bash
#> args:
#> - -c
#> - gcloud secrets versions access latest --secret=github-ssh --format='get(payload.data)'
#> | tr '_-' '/+' | base64 -d > /root/.ssh/id_rsa
#> id: git secret
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[2]]
#> ==cloudRunnerBuildStep==
#> 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
#>
#> [[3]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - clone
#> - git@github.com:MarkEdmondson1234/googleCloudRunner
#> - repo
#> id: clone to repo dir
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[4]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/gcer-public/packagetools:latest
#> args:
#> - Rscript
#> - -e
#> - |-
#> devtools::install_deps(dependencies=TRUE)
#> devtools::install_local()
#> pkgdown::build_site()
#> id: build pkgdown
#> dir: repo
#>
#> [[5]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - add
#> - --all
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[6]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - commit
#> - -a
#> - -m
#> - "[skip ci] Build website from commit ${COMMIT_SHA}: \n$(date +\"%Y%m%dT%H:%M:%S\")"
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[7]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - status
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[8]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - push
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
# github repo set via build trigger macro _GITHUB_REPO
cr_buildstep_pkgdown("$_GITHUB_REPO",
git_email = "cloudbuild@google.com",
secret = "github-ssh"
)
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/gcloud
#> entrypoint: bash
#> args:
#> - -c
#> - gcloud secrets versions access latest --secret=github-ssh --format='get(payload.data)'
#> | tr '_-' '/+' | base64 -d > /root/.ssh/id_rsa
#> id: git secret
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[2]]
#> ==cloudRunnerBuildStep==
#> 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
#>
#> [[3]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - clone
#> - git@github.com:$_GITHUB_REPO
#> - repo
#> id: clone to repo dir
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[4]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/gcer-public/packagetools:latest
#> args:
#> - Rscript
#> - -e
#> - |-
#> devtools::install_deps(dependencies=TRUE)
#> devtools::install_local()
#> pkgdown::build_site()
#> id: build pkgdown
#> dir: repo
#>
#> [[5]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - add
#> - --all
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[6]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - commit
#> - -a
#> - -m
#> - "[skip ci] Build website from commit ${COMMIT_SHA}: \n$(date +\"%Y%m%dT%H:%M:%S\")"
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[7]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - status
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[8]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - push
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
# example including environment arguments for pkgdown build step
cr_buildstep_pkgdown("$_GITHUB_REPO",
git_email = "cloudbuild@google.com",
secret = "github-ssh",
env = c("MYVAR=$_MY_VAR", "PROJECT=$PROJECT_ID")
)
#> [[1]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/gcloud
#> entrypoint: bash
#> args:
#> - -c
#> - gcloud secrets versions access latest --secret=github-ssh --format='get(payload.data)'
#> | tr '_-' '/+' | base64 -d > /root/.ssh/id_rsa
#> id: git secret
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[2]]
#> ==cloudRunnerBuildStep==
#> 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
#>
#> [[3]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - clone
#> - git@github.com:$_GITHUB_REPO
#> - repo
#> id: clone to repo dir
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[4]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/gcer-public/packagetools:latest
#> args:
#> - Rscript
#> - -e
#> - |-
#> devtools::install_deps(dependencies=TRUE)
#> devtools::install_local()
#> pkgdown::build_site()
#> id: build pkgdown
#> dir: repo
#> env:
#> - MYVAR=$_MY_VAR
#> - PROJECT=$PROJECT_ID
#>
#> [[5]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - add
#> - --all
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[6]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - commit
#> - -a
#> - -m
#> - "[skip ci] Build website from commit ${COMMIT_SHA}: \n$(date +\"%Y%m%dT%H:%M:%S\")"
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[7]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - status
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>
#> [[8]]
#> ==cloudRunnerBuildStep==
#> name: gcr.io/cloud-builders/git
#> args:
#> - push
#> dir: repo
#> volumes:
#> - name: ssh
#> path: /root/.ssh
#>