Update deploy-shiny.yaml #514
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 | |
name: deploy-shiny | |
jobs: | |
deployShiny: | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
r-version: 4.4.1 | |
- name: Set env vars (dev) | |
if: endsWith(github.ref, '/development') | |
run: | | |
echo "SHINYAPP_NAME='dev-local-skills-dashboard'" >> $GITHUB_ENV | |
- name: Set env vars (prod) | |
if: endsWith(github.ref, '/main') | |
run: | | |
echo "SHINYAPP_NAME='local-skills-dashboard'">> $GITHUB_ENV | |
- name: Install git2r dependencies | |
run: sudo apt-get install -y libgit2-dev | |
- name: Install proj library (terra depdencies) | |
run: sudo apt-get install libproj-dev | |
- name: Install gdal library (terra dependencies) | |
run: sudo apt-get install libgdal-dev | |
- name: Install udunits library (units dependencies) | |
run: sudo apt-get install libudunits2-dev | |
- 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: | | |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv") | |
renv::install("rsconnect") | |
# Tokens are stored as secrets in GitHub to make sure only DfE analysts can publish apps in our shiny.io area | |
# Navigate to Settings > Secrets to add and view secrets. These can also be things like admin login and passwords for SQL databases. | |
# Get in touch with the Stats Development team if you need to add the below secrets to publish to shinyapps.io | |
- 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)" |