4 CI/CD pipelines for automatic deployment of a R Shiny web app

It is good practice to integrate and develop an R Shiny app as an R package, to take full advantage of all the integrated features established for R packages (e.g., documentation, package namespaces, automated testing, R CMD check, etc.). A typical development workflow to package a Shiny app is provided by the golem package. Later in this chapter we will also indicate how to package a shiny app without the infrastructure provided by golem.

Furthermore, version control systems such as Git are a great asset for keeping track an manage changes, especially in a collaborative setup.

The development of a packaged Shiny app under version control can easily enable and take advantage of:

  • Continuous Integration (CI) pipelines to automate checks and ensure higher code quality and robustness;
  • Continuous Deployment (CD) pipelines to automate the process of deployment to a productive environment.

This guide illustrates how to set up CI/CD pipelines with a focus on the increasingly popular GitHub Actions, which we recommend as a natural choice for GitHub open source projects. In particular, it shows how a Shiny app developed as an R package can be maintained on a GitHub repository, be deployed to and hosted on shinyapps.io using said CI/CD pipelines. For the sake of completeness, and for historical reasons, the guide also covers the CI/CD setup on Travis CI, a well established service that has become not attractive any longer for open source projects due to its change of policy in recent years.

ShinyCICD is a minimal example of a packaged Shiny app that will be used as an example throughout the guide. You can simply fork the repository and setup your specific user settings (especially for shinyapps.io) to see CI/CD pipelines in actions, or follow the steps described below to setup CI/CD pipelines for your own app.