Import, Render and Publish #82
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: | |
schedule: | |
# time is in UTC i.e. GMT London | |
# * is a special character in YAML so you have to quote this string | |
- cron: '30 13 * * *' | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
name: Import, Render and Publish | |
# you need these permissions to publish to GitHub pages | |
permissions: | |
contents: write | |
pages: write | |
jobs: | |
import-render-publish: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 and install requirements | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: 'pip' # caching pip dependencies | |
- run: pip install -r requirements.txt | |
- name: Import Unjournal data | |
run: | | |
python3 code/import-unjournal-data.py | |
env: | |
CODA_API_KEY: ${{ secrets.CODA_API_KEY }} | |
- name: Upload Unjournal data as artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: unjournal-data | |
path: data | |
- name: Update Unjournal data in repository | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "Github Actions" | |
git add data/*.csv | |
git diff-index HEAD data/*.csv || git commit -m "Github actions: auto-update data" | |
git push | |
- name: Set up Quarto | |
uses: quarto-dev/quarto-actions/setup@v2 | |
# uncomment below and fill to pin a version | |
# version: SPECIFIC-QUARTO-VERSION-HERE | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 'renv' | |
- name: Install system dependencies | |
run: | | |
sudo apt-get install jags libcurl4-openssl-dev \ | |
libharfbuzz-dev libfribidi-dev libsodium-dev | |
- name: Setup dependencies with renv | |
uses: r-lib/actions/setup-renv@v2 | |
with: | |
cache-version: 2 # increment this to invalidate the renv cache | |
env: | |
GITHUB_PAT: ${{ secrets.RENV_GITHUB_PAT }} | |
- name: Publish dashboard to shinyapps.io | |
env: | |
RSCONNECT_USER: ${{ secrets.RSCONNECT_USER }} | |
RSCONNECT_TOKEN: ${{ secrets.RSCONNECT_TOKEN }} | |
RSCONNECT_SECRET: ${{ secrets.RSCONNECT_SECRET }} | |
AIRTABLE_API_KEY: ${{ secrets.AIRTABLE_API_KEY }} | |
run: | | |
rsconnect::setAccountInfo(name = Sys.getenv("RSCONNECT_USER"), | |
token = Sys.getenv("RSCONNECT_TOKEN"), | |
secret = Sys.getenv("RSCONNECT_SECRET")) | |
quarto::quarto_publish_app(input = "shinyapp/dashboard", | |
account = "unjournal", | |
server = "shinyapps.io", | |
forceUpdate = TRUE) | |
shell: Rscript {0} | |
# - name: Publish DataExplorer to shinyapps.io | |
# env: | |
# RSCONNECT_USER: ${{ secrets.RSCONNECT_USER }} | |
# RSCONNECT_TOKEN: ${{ secrets.RSCONNECT_TOKEN }} | |
# RSCONNECT_SECRET: ${{ secrets.RSCONNECT_SECRET }} | |
# run: | | |
# source("code/create-data-for-DataExplorer.R") | |
# rsconnect::setAccountInfo(name = Sys.getenv("RSCONNECT_USER"), | |
# token = Sys.getenv("RSCONNECT_TOKEN"), | |
# secret = Sys.getenv("RSCONNECT_SECRET")) | |
# rsconnect::deployApp(appDir = "shinyapp/DataExplorer", | |
# appName = "DataExplorer", | |
# account = "unjournal", | |
# server = "shinyapps.io", | |
# forceUpdate = TRUE) | |
# shell: Rscript {0} | |