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 on the popular free and open source services Travis CI and GitHub Actions for a packaged Shiny app on a GitHub repository, deployed and hosted on shinyapps.io.

As a side note, Travis CI’s change in policy does not make it advantageous for open source projects any longer, as they usually rely on free plans. We therefore suggest to use GitHub Actions for open source projects.

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.