Skip to content

Instantly share code, notes, and snippets.

@cderv
Created December 10, 2020 14:12
Show Gist options
  • Save cderv/a002abe93261c6fe0db932700821342e to your computer and use it in GitHub Desktop.
Save cderv/a002abe93261c6fe0db932700821342e to your computer and use it in GitHub Desktop.
Deploy Bookdown to RStudio Connect programatically

How to deploy to Rstudio Connect : Push mode

Theory

  • Create a manifest using rsconnect
  • Use API to create content on RSC -> GUID
  • Create a tar.gz bunlde with the manifest
  • USe API to push the bundle

Creating a Manifest

Requires the rsconnect package

rsconnect::writeManifest()

Using the connectapi package

Only use a name to identify

In this case a content will

library(connectapi)
client <- connect("https://beta.rstudioconnect.com/", Sys.getenv("RSC_BETA_TOKEN"))
bundle <- bundle_dir(book_dir)
depl <- deploy(client, bundle, name = "demo-book")
poll_task(depl)

Using bash (with curl and jq)

https://github.com/rstudio/connect-api-deploy-shiny/tree/master/deploy

Using rsconnect-python

https://pypi.org/project/rsconnect-python/

Example with a manifest

pip install rsconnect-python
rsconnect deploy manifest ${{ steps.built-book.outputs.dir}} \
  -s $CONNECT_SERVER
  -k $CONNECT_API_KEY
  -a $CONTENT_ID
  -t "Demo book deployed with rsconnect-python"
  -v

Using rsconnect-ts

https://github.com/rstudio/rsconnect-ts/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment