Work around Netlify Unprocessable Entity error #464
This file contains hidden or 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: [push, pull_request] | |
name: build | |
permissions: | |
contents: write | |
deployments: write | |
statuses: write | |
jobs: | |
build-r: | |
runs-on: ${{ matrix.config.os }} | |
name: 'R: ${{ matrix.config.r }} (${{ matrix.config.os }})' | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { os: macOS-latest, r: 'release' } | |
- { os: windows-latest, r: 'release' } | |
- { os: windows-latest, r: 'oldrel' } | |
- { os: ubuntu-22.04, r: 'devel', http-user-agent: 'release' } | |
- { os: ubuntu-22.04, r: 'release', release: true } | |
- { os: ubuntu-22.04, r: 'oldrel-1' } | |
- { os: ubuntu-22.04, r: 'oldrel-2' } | |
- { os: ubuntu-22.04, r: 'oldrel-3' } | |
- { os: ubuntu-22.04, r: 'oldrel-4' } | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
R_KEEP_PKG_SOURCE: yes | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- name: Configure pak and setup-r action to use manylinux_2_28 | |
if: startsWith(matrix.config.os, 'ubuntu') && matrix.config.r != 'devel' | |
run: | | |
# Override PPM repo and do not autodetect the distro (setup-r action env var) | |
echo "RSPM=https://p3m.dev/cran/__linux__/manylinux_2_28/latest" >> $GITHUB_ENV | |
# Disable automatic system requirements installation since it is unnecessary (pak env var) | |
echo "PKG_SYSREQS=FALSE" >> $GITHUB_ENV | |
- uses: r-lib/actions/setup-r@v2 | |
with: | |
r-version: ${{ matrix.config.r }} | |
http-user-agent: ${{ matrix.config.http-user-agent }} | |
use-public-rspm: true | |
- uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
# leaflet needs terra, which does not support R <= 4.0 | |
extra-packages: | | |
any::rcmdcheck | |
leaflet=?ignore-before-r=4.1.0 | |
- uses: r-lib/actions/check-r-package@v2 | |
- name: Test coverage | |
if: matrix.config.release | |
run: covr::codecov(quiet = FALSE) | |
shell: Rscript {0} | |
- name: Install pkgdown dependencies | |
if: matrix.config.release | |
uses: r-lib/actions/setup-r-dependencies@v2 | |
with: | |
# Pin pkgdown to 2.0.9 for bug with using image filenames with spaces, and Quarto needs to be set up as well | |
extra-packages: local::., pkgdown@2.0.9 | |
- name: Build pkgdown site | |
if: matrix.config.release | |
run: Rscript pkgdown/build-docs.R | |
- name: Set Netlify alias | |
if: matrix.config.release | |
run: | | |
version="v$(cat DESCRIPTION | grep Version: | cut -d' ' -f2)" | |
# Netlify aliases can't have periods, so replace them with dashes | |
version_alias=${version//./-} | |
if [ "$GITHUB_REF" = "refs/heads/$version" ]; then | |
echo "NETLIFY_ALIAS=$version_alias" >> $GITHUB_ENV | |
else | |
github_sha_short=$(echo $GITHUB_SHA | cut -c 1-7) | |
echo "NETLIFY_ALIAS=${version_alias}-${github_sha_short}" >> $GITHUB_ENV | |
fi | |
- name: Rebuild pkgdown site search index for GitHub Pages | |
if: matrix.config.release && github.ref == 'refs/heads/main' | |
run: Rscript pkgdown/build-search-gh.R | |
- name: Deploy pkgdown site to GitHub Pages | |
if: matrix.config.release && github.ref == 'refs/heads/main' | |
uses: JamesIves/github-pages-deploy-action@v4.4.3 | |
with: | |
branch: gh-pages | |
folder: docs | |
- name: Deploy pkgdown site to Netlify | |
if: matrix.config.release | |
uses: nwtgck/actions-netlify@v3.0 | |
with: | |
publish-dir: './docs' | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
alias: ${{ env.NETLIFY_ALIAS }} | |
deploy-message: 'Deploy from GitHub Actions: ${{ github.ref }} (${{ github.sha }})' | |
enable-pull-request-comment: false | |
enable-commit-comment: false | |
env: | |
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} | |
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} | |
timeout-minutes: 5 | |
# Work around Netlify error of "Error: Unprocessable Entity" even though the deployment succeeds | |
continue-on-error: true | |
build-node: | |
runs-on: ubuntu-latest | |
name: Node.js | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '22' | |
cache: 'npm' | |
- name: Install dependencies | |
run: npm install | |
- name: Test | |
run: npm run test:cover | |
- name: Lint | |
run: npm run lint | |
- name: Upload coverage to Codecov | |
uses: codecov/codecov-action@v4 |