Docs site #7
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: R | |
on: [push, pull_request] | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
jobs: | |
pre_deploy: | |
runs-on: ubuntu-latest | |
env: | |
cache-version: 5 | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up libraries for Ubuntu | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y libsodium-dev libharfbuzz-dev libfribidi-dev libcurl4-openssl-dev texlive-latex-base texlive-fonts-extra pandoc libmagick++-dev libhdf5-dev | |
- name: Set up R 4.0 | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: 4.0 | |
- name: Set CRAN mirror | |
run: | | |
cat("\noptions(repos=structure(c(CRAN=\"https://cran.rstudio.com\")))\n", file = "~/.Rprofile", append = TRUE) | |
shell: Rscript {0} | |
- name: Get R and OS version | |
id: get-version | |
run: | | |
cat("::set-output name=os-version::", sessionInfo()$running, "\n", sep = "") | |
cat("::set-output name=r-version::", R.Version()$version.string, "\n", sep = "") | |
cat("::endgroup::\n") | |
shell: Rscript {0} | |
- name: Cache dependencies | |
id: cache-deps | |
uses: actions/cache@v2 | |
with: | |
path: ${{ env.R_LIBS_USER }}/* | |
key: ${{ hashFiles('DESCRIPTION') }}-${{ steps.get-version.outputs.os-version }}-${{ steps.get-version.outputs.r-version }}-${{ env.cache-version }}-deps | |
- name: Install dependencies | |
if: steps.cache-deps.outputs.cache-hit != 'true' | |
run: | | |
install.packages(c("devtools", "remotes", "rcmdcheck", "covr")) | |
remotes::install_deps(dependencies = TRUE) | |
shell: Rscript {0} | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
- name: rcmdcheck | |
run: | | |
rcmdcheck::rcmdcheck( | |
error_on = "error", # TODO: switch back to "warning" | |
check_dir = "check" | |
) | |
shell: Rscript {0} | |
env: | |
_R_CHECK_FORCE_SUGGESTS_: false | |
- name: Run coverage report | |
run: | | |
covr::package_coverage() | |
shell: Rscript {0} | |
- name: Downgrade pkgdown | |
run: | | |
remotes::install_version("pkgdown", "2.0.3") | |
shell: Rscript {0} | |
- name: Build docs | |
run: | | |
Rscript -e 'devtools::document(); pkgdown::build_site(new_process = FALSE)' | |
touch docs/.nojekyll | |
- uses: actions/upload-pages-artifact@v1 | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
with: | |
path: ./docs | |
deploy: | |
runs-on: ubuntu-latest | |
needs: pre_deploy | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
uses: actions/deploy-pages@v1 |