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
)

Arguments

github_repo

The GitHub repo to deploy pkgdown website from and to.

git_email

The email the git commands will be identifying as

secret

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

env

A character vector of env arguments to set for all steps

build_image

A docker image with pkgdown installed

post_setup

Steps that occur after git setup

post_clone

A cr_buildstep that occurs after the repo is cloned

Details

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

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"
# 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 > /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 travis] 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 > /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 travis] 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 > /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 travis] 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 #>