Skip to content

CI-CD

CI-CD #364

Workflow file for this run

# 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
name: CI-CD
# Create status badge with usethis::use_github_actions_badge("ci-cd.yml")
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 * *'
# Avoid concurrent deployments from both workflows by running one at a time
# (specific for ShinyCICD maintenance)
concurrency:
group: shinyapps-${{ github.ref }}
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
# rsconnect needs transitive LinkingTo-only dependencies to be installed
# (see https://github.com/r-lib/pak/issues/485)
PKG_INCLUDE_LINKINGTO: true
steps:
- name: Checkout repo
uses: actions/checkout@v4
- 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 and cache dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: any::rcmdcheck
- 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: 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