Update main.yml #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Shiny App | |
on: | |
push: | |
branches: | |
- master # Trigger deployment on push to master branch | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the code | |
uses: actions/checkout@v3 | |
- name: Install system dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libcurl4-openssl-dev libssl-dev | |
- name: Set up R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: '4.2.1' # Specify the version of R | |
- name: Install remotes to handle GitHub installations | |
run: | | |
Rscript -e 'install.packages("remotes", repos="https://cloud.r-project.org")' | |
- name: Install rsconnect from CRAN with logs | |
run: | | |
Rscript -e 'install.packages("rsconnect", repos="https://cloud.r-project.org", dependencies = TRUE)' | |
Rscript -e 'print("rsconnect successfully installed.")' | |
- name: Verify rsconnect is installed | |
run: | | |
Rscript -e 'if (!"rsconnect" %in% installed.packages()) stop("rsconnect not installed")' | |
- name: Deploy to shinyapps.io | |
env: | |
SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }} | |
SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }} | |
run: | | |
Rscript -e 'library(rsconnect)' # Ensure rsconnect is loaded | |
Rscript -e 'rsconnect::setAccountInfo(name="worldhealthorg", token=Sys.getenv("SHINYAPPS_TOKEN"), secret=Sys.getenv("SHINYAPPS_SECRET"))' | |
Rscript -e 'rsconnect::deployApp(appFiles=".", appName="GSHS", account="worldhealthorg", forceUpdate=TRUE)' |