restore develop (#254) #2519
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
name: CI-CD | |
# renv with GitHub actions: https://rstudio.github.io/renv/articles/ci.html#github-actions | |
# Triggered on push and pull request events, schedule for data update | |
on: | |
push: | |
pull_request: | |
schedule: | |
# every day at 21 UTC | |
- cron: "0 21 * * *" | |
jobs: | |
CI-CD: | |
runs-on: ${{ matrix.config.os }} | |
name: ${{ matrix.config.os }} (${{ matrix.config.r }}) | |
strategy: | |
# We keep a matrix for convenience, but we would typically just run on one | |
# single OS and R version, aligned with the target deployment environment | |
matrix: | |
config: | |
- {os: ubuntu-latest, r: '4.2.1'} | |
env: | |
# Access token for GitHub | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
# Preserve package sources for informative references in case of errors | |
R_KEEP_PKG_SOURCE: yes | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r }} | |
# Enable RStudio Package Manager to speed up package installation | |
use-public-rspm: true | |
# - name: Install system dependencies | |
# # This is not taken care of (yet) by r-lib/actions/setup-renv | |
# # Package distro used to get the distro for the used ubuntu-latest | |
# run: | | |
# Rscript -e "install.packages(c('remotes', 'distro'))" | |
# while read -r cmd | |
# do | |
# eval sudo $cmd | |
# done < <(Rscript -e 'writeLines(with(distro::distro(), remotes::system_requirements(id, short_version)))') | |
- name: Activate renv and restore packages with cache | |
uses: r-lib/actions/setup-renv@v2 | |
# - name: Install renv Development tools | |
# run: renv::install() | |
# shell: Rscript {0} | |
- name: Fetch and rebuild latest data | |
if: github.event_name == 'schedule' | |
run: | | |
pkgload::load_all(export_all = FALSE, helpers = FALSE, attach_testthat = FALSE) | |
build_data() | |
shell: Rscript {0} | |
- name: Install R CMD check | |
run: install.packages("rcmdcheck") | |
shell: Rscript {0} | |
- name: Check package | |
uses: r-lib/actions/check-r-package@v2 | |
- name: Commit and push updated data | |
if: github.event_name == 'schedule' | |
run: | | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
git add inst/datahub/\* | |
git commit -m "Update DataHub data" || echo "No changes to commit" | |
git pull --ff-only | |
git push origin | |
- name: Deploy to shinyapps.io | |
# Continuous deployment only for pushes to the main / master branch | |
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' | |
env: | |
SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }} | |
SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }} | |
SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }} | |
run: Rscript deploy/deploy-shinyapps.R |