Skip to content

shiny-deploy

shiny-deploy #880

Workflow file for this run

# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
branches: [main, master]
schedule:
- cron: "0 0 * * *"
name: shiny-deploy
jobs:
shiny-deploy:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RSCONNECT_USER: ${{ secrets.RSCONNECT_USER }}
RSCONNECT_TOKEN: ${{ secrets.RSCONNECT_TOKEN }}
RSCONNECT_SECRET: ${{ secrets.RSCONNECT_SECRET }}
RENV_PATHS_ROOT: ~/.local/share/renv
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.local/share/renv
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- name: Install curl
run: sudo apt -y install libcurl4-openssl-dev
- name: Restore packages
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::restore()
shell: Rscript {0}
- uses: r-lib/actions/setup-pandoc@v2
- name: Update data
run: |
source("R/data_etl.R")
shell: Rscript {0}
- name: Authorize and deploy app
run: |
git_status <- system(command = "git status", intern = TRUE) |>
paste(collapse = " ")
if (grepl(pattern = "nothing to commit, working tree clean", x = git_status)) {
message("Working tree is clean. Skipping deployment.")
} else {
rsconnect::setAccountInfo(
name = '${{ secrets.RSCONNECT_USER }}',
token = '${{ secrets.RSCONNECT_TOKEN }}',
secret = '${{ secrets.RSCONNECT_SECRET }}'
)
rsconnect::deployApp(forceUpdate = TRUE)
}
shell: Rscript {0}
- name: Commit results
run: |
git config --local user.name "GitHub Actions"
git config --local user.email "actions@github.com"
git add .
git commit -m "Update data and deploy shiny app" || echo "No changes to commit"
git push origin || echo "No changes to commit"