R/deploy.R
cr_deploy_pkgdown.Rd
This builds a pkgdown website each time the trigger fires and deploys it to git
cr_deploy_pkgdown( github_repo, secret, steps = NULL, create_trigger = c("file", "inline", "no"), cloudbuild_file = "cloudbuild-pkgdown.yml", git_email = "googlecloudrunner@r.com", env = NULL, build_image = "gcr.io/gcer-public/packagetools:latest", post_setup = NULL, post_clone = NULL )
github_repo | The GitHub repo to deploy pkgdown website from and to. |
---|---|
secret | The name of the secret on Google Secret Manager for the git ssh private key |
steps | extra steps to run before the pkgdown website steps run |
create_trigger | If not "no" then the buildtrigger will be setup for you via cr_buildtrigger, if "file" will create a buildtrigger pointing at |
cloudbuild_file | The cloudbuild yaml file to write to |
git_email | The email the git commands will be identifying as |
env | A character vector of env arguments to set for all steps |
build_image | A docker image with |
post_setup | Steps that occur after git setup |
post_clone | A cr_buildstep that occurs after the repo is cloned |
The trigger repository needs to hold an R package configured to build a pkgdown website.
For GitHub, the repository will also need to be linked to the project you are building within, via https://console.cloud.google.com/cloud-build/triggers/connect
The git ssh keys need to be deployed to Google Secret Manager for the deployment of the website - see cr_buildstep_git - this only needs to be done once per Git account.
Create your own custom deployment using cr_buildstep_pkgdown which this function uses with some defaults.
Other Deployment functions:
cr_deploy_docker_trigger()
,
cr_deploy_docker()
,
cr_deploy_packagetests()
,
cr_deploy_run_website()
,
cr_deploy_run()
,
cr_deploy_r()
pd <- cr_deploy_pkgdown("MarkEdmondson1234/googleCloudRunner", secret = "my_git_secret", create_trigger = "no")#>#>#> ℹ Complete deployment of pkgdown Cloud Build yaml:#> ● Go to https://console.cloud.google.com/cloud-build/triggers and #> #>#> ℹ Ignored files filter (glob): docs/**, inst/**, tests/**pd#> ==CloudBuildObject== #> steps: #> - name: gcr.io/cloud-builders/gcloud #> entrypoint: bash #> args: #> - -c #> - gcloud secrets versions access latest --secret=my_git_secret > /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:MarkEdmondson1234/googleCloudRunner #> - repo #> id: clone to repo dir #> volumes: #> - name: ssh #> path: /root/.ssh #> - 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 #> - name: gcr.io/cloud-builders/git #> args: #> - add #> - --all #> dir: repo #> volumes: #> - name: ssh #> path: /root/.ssh #> - 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 #> - name: gcr.io/cloud-builders/git #> args: #> - status #> dir: repo #> volumes: #> - name: ssh #> path: /root/.ssh #> - name: gcr.io/cloud-builders/git #> args: #> - push #> dir: repo #> volumes: #> - name: ssh #> path: /root/.ssh#> [1] TRUEunlink("cloudbuild-pkgdown.yml") if (FALSE) { cr_deploy_pkgdown("MarkEdmondson1234/googleCloudRunner", secret = "my_git_secret", create_trigger = "inline") }