Panel scripts #104
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
on: | |
push: | |
branches: | |
- main | |
- development | |
pull_request: | |
branches: | |
- main | |
- development | |
name: deploy-shiny | |
jobs: | |
deployShiny: | |
runs-on: macOS-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 4.4.1 | |
use-public-rspm: true | |
- name: Set env vars (dev) | |
if: endsWith(github.ref, '/development') | |
run: | | |
echo "SHINYAPP_NAME='dev-leo-graduate-industry-dashboard'" >> $GITHUB_ENV | |
- name: Set env vars (prod) | |
if: endsWith(github.ref, '/main') | |
run: | | |
echo "SHINYAPP_NAME='leo-graduate-industry-dashboard'">> $GITHUB_ENV | |
- name: Cache R packages | |
if: runner.os != 'Windows' | |
uses: actions/cache@v1 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} | |
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- | |
- name: Restore renv snapshot | |
shell: Rscript {0} | |
run: | | |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") | |
renv::restore() | |
- name: Install rsconnect | |
shell: Rscript {0} | |
run: | | |
install.packages("rsconnect") | |
- name: Push to shiny.io | |
if: github.event_name != 'pull_request' | |
run: > | |
Rscript | |
-e "rsconnect::setAccountInfo(name = 'department-for-education', token = '${{secrets.SHINYAPPS_TOKEN}}', secret = '${{secrets.SHINYAPPS_SECRET}}')" | |
-e "rsconnect::deployApp(appName=${{env.SHINYAPP_NAME}}, forceUpdate = TRUE)" |