Skip to content

shinyapps-io-deploy #15

shinyapps-io-deploy

shinyapps-io-deploy #15

# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
name: shinyapps-io-deploy
on:
pull_request:
types:
- closed
workflow_dispatch:
jobs:
shinyapps-io-deploy:
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- name: Install System Dependencies
run: |
sudo apt-get update
sudo apt-get install -y pip python3-venv libcurl4-openssl-dev
- uses: actions/checkout@v2
- name: disable renv
run: |
rm .Rprofile
rm renv.lock
rm -rf renv
- name: Install R packages
run: |
# The binary package distributions from R Studio dramatically speed up installation time
options(repos = c(REPO_NAME = "https://packagemanager.rstudio.com/all/__linux__/focal/latest",
getOption("repos")))
install.packages(c("dplyr", "purrr", "reactable", "shiny", "rsconnect", "rjson", "httr"))
shell: sudo Rscript {0} # running this step as 'sudo' is necessary to be able to install packages in default library
- name: Authorize and deploy app
run: |
branch<-Sys.getenv("GITHUB_REF_NAME")
repo<-Sys.getenv("GITHUB_REPOSITORY")
appName<-strsplit(repo, "/")[[1]][2]
if (!startsWith(branch, "prod")) {
appName = paste(appName, "staging", sep="-")
}
rsConnectUser <-"${{ secrets.RSCONNECT_USER }}"
rsConnectToken <- "${{ secrets.RSCONNECT_TOKEN }}"
rsConnectSecret <- "${{ secrets.RSCONNECT_SECRET }}"
rsconnect::setAccountInfo(rsConnectUser, rsConnectToken, rsConnectSecret)
appFiles<-dir(all.files=TRUE, include.dirs=TRUE)
rsconnect::deployApp(appName = appName, appFiles=appFiles, forceUpdate = TRUE)
# important NOT to run this step as sudo, otherwise env var's will be missing
shell: Rscript {0}