Skip to content

Commit

Permalink
Added development deploy to deploy script
Browse files Browse the repository at this point in the history
  • Loading branch information
rmbielby committed Nov 10, 2023
1 parent c9f1822 commit c767eb6
Showing 1 changed file with 93 additions and 26 deletions.
119 changes: 93 additions & 26 deletions .github/workflows/deploy-shiny.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,10 @@ on:
push:
branches:
- master
- development

name: deploy-shiny

# jobs:
# deploy-shiny:
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v2
# - uses: r-lib/actions/setup-r@v2
# with:
# r-version: 4.2.1
# use-public-rspm: true
#
# - name: Install Curl
# run: sudo apt install libcurl4-openssl-dev libssl-dev
# - name: Restore renv snapshot
# shell: Rscript {0}
# run: |
# if (!require('renv')) install.packages('renv')
# renv::restore()
# - name: Push to shiny.io
# run: >
# Rscript
# -e "rsconnect::setAccountInfo(name='department-for-education', token='${{secrets.SHINYAPPS_TOKEN}}', secret='${{secrets.SHINYAPPS_SECRET}}')"
# -e "rsconnect::deployApp()"
#

jobs:
deployShiny:
runs-on: ${{ matrix.config.os }}
Expand All @@ -55,6 +32,56 @@ jobs:
r-version: 4.2.1
use-public-rspm: true

- name: Set env vars (dev)
if: endsWith(github.ref, '/development')
run: |
echo "SHINYAPP_NAME='dev-pupil-attendance-in-schools'" >> $GITHUB_ENV
echo "SHINYAPP_OVERFLOW_NAME='dev-pupil-attendance-in-schools-overflow'">> $GITHUB_ENV
- name: Set env vars (prod)
if: endsWith(github.ref, '/main')
run: |
echo "SHINYAPP_NAME='on:
push:
branches:
- main
- development

name: deploy-shiny

jobs:
deployShiny:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
# Running on mac as it's quicker to build
- {os: macOS-latest, r: 'release'}

env:
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true
RSPM: ${{ matrix.config.rspm }}
RENV_PATHS_ROOT: ~/.local/share/renv

steps:
- uses: actions/checkout@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: 4.2.1
use-public-rspm: true

- name: Set env vars (dev)
if: endsWith(github.ref, '/development')
run: |
echo "SHINYAPP_NAME='dev-ks5-transition-matrices'" >> $GITHUB_ENV
- name: Set env vars (prod)
if: endsWith(github.ref, '/main')
run: |
echo "SHINYAPP_NAME='ks5-transition-matrices'">> $GITHUB_ENV
- name: Cache R packages
if: runner.os != 'Windows'
uses: actions/cache@v1
Expand Down Expand Up @@ -82,13 +109,53 @@ jobs:
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::install("[email protected]")
# 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
run: >
Rscript
-e "rsconnect::setAccountInfo(name = 'department-for-education', token = '${{secrets.SHINYAPPS_TOKEN}}', secret = '${{secrets.SHINYAPPS_SECRET}}')"
-e "rsconnect::deployApp(appName=${{env.SHINYAPP_NAME}})"
-e "rsconnect::deployApp(appName=${{env.SHINYAPP_OVERFLOW_NAME}})"'">> $GITHUB_ENV
echo "SHINYAPP_OVERFLOW_NAME='pupil-attendance-in-schools-overflow'">> $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: Cache renv packages
uses: actions/cache@v1
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- 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("[email protected]")
# 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
run: >
Rscript
-e "rsconnect::setAccountInfo(name='department-for-education', token='${{secrets.SHINYAPPS_TOKEN}}', secret='${{secrets.SHINYAPPS_SECRET}}')"
-e "rsconnect::deployApp()"
-e "rsconnect::setAccountInfo(name = 'department-for-education', token = '${{secrets.SHINYAPPS_TOKEN}}', secret = '${{secrets.SHINYAPPS_SECRET}}')"
-e "rsconnect::deployApp(appName=${{env.SHINYAPP_NAME}})"

0 comments on commit c767eb6

Please sign in to comment.