wip #226
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
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples | |
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help | |
# Name of the workflow => usethis::use_github_actions_badge("CI-CD-renv") | |
name: CI-CD-renv | |
on: | |
# Triggered on push and pull request events | |
push: | |
pull_request: | |
# Allow manual runs from the Actions tab | |
workflow_dispatch: | |
# Monthly runs on the 1st day of the month at midnight | |
# (specific for ShinyCICD maintenance) | |
schedule: | |
- cron: '0 0 1 * *' | |
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: 'release'} | |
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 }} | |
# No RStudio Package Manager to respect renv.lock | |
use-public-rspm: false | |
- name: Install system dependencies | |
# This is not taken care of (yet) by r-lib/actions/setup-renv | |
# We could use pak-based installation for renv, which includes system | |
# requirements, but would have to handle the pak cache explicitly | |
# See https://github.com/r-lib/actions/issues/785 | |
run: | | |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/stable/") | |
install.packages("jsonlite") | |
print(str(jsonlite::read_json("renv.lock"), max.level=2)) | |
print(names(jsonlite::read_json("renv.lock")[["Packages"]])) | |
pak::sysreqs_fix_installed(names(jsonlite::read_json("renv.lock")[["Packages"]])) | |
shell: Rscript {0} | |
- name: Activate renv and restore packages with cache | |
uses: r-lib/actions/setup-renv@v2 | |
- name: Install R CMD check | |
run: install.packages("rcmdcheck") | |
shell: Rscript {0} | |
- name: Check package | |
uses: r-lib/actions/check-r-package@v2 | |
- name: Deploy to shinyapps.io | |
# Continuous deployment only for pushes to the main / master branch | |
if: true || (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 |