Fix issues in api chapter and interactive graphics duplication #461
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
name: Render and deploy Quarto files | |
on: | |
push: | |
pull_request: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
env: | |
DOCKER_BUILDKIT: 1 | |
NEWSAPI_KEY: ${{ secrets.NEWSAPI_KEY }} | |
GH_APP_ID: ${{ secrets.GH_APP_ID }} | |
GH_APP_SECRET: ${{ secrets.GH_APP_SECRET }} | |
GH_PAT_DEMO: ${{ secrets.GH_PAT_DEMO }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
GH_PAT: ${{ secrets.GH_PAT }} | |
GITHUB_PAT: ${{ secrets.GH_PAT }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
# Make sure caches exist even on first run | |
- name: Prepare cache dirs | |
run: | | |
mkdir -p ~/.cache/pip | |
mkdir -p ~/.local/share/renv | |
- name: Cache pip (downloads/wheels) | |
uses: actions/cache@v4 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('setup/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Cache renv (global cache, not project folder) | |
uses: actions/cache@v4 | |
with: | |
path: ~/.local/share/renv | |
key: ${{ runner.os }}-renv-${{ hashFiles('setup/renv.lock') }} | |
restore-keys: | | |
${{ runner.os }}-renv- | |
- name: Build Docker image with layer cache | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: false | |
load: true | |
tags: local/quarto-reticulate:latest | |
cache-from: type=gha | |
cache-to: type=gha,mode=max | |
# Run inside the container against the mounted repo | |
- name: Render | |
run: | | |
docker run --rm \ | |
-v "${{ github.workspace }}:/project" \ | |
-v "${HOME}/.local/share/renv:/root/.local/share/renv" \ | |
-v "${HOME}/.cache/pip:/root/.cache/pip" \ | |
-e RENV_PATHS_CACHE=${HOME}/.local/share/renv \ | |
-e RENV_PATH=/opt/renv \ | |
-e VENV_PATH=/opt/venv \ | |
-e PIP_CACHE_DIR=${HOME}/.cache/pip \ | |
-e NEWSAPI_KEY="${{ secrets.NEWSAPI_KEY }}" \ | |
-e GH_APP_ID="${{ secrets.GH_APP_ID }}" \ | |
-e GH_APP_SECRET="${{ secrets.GH_APP_SECRET }}" \ | |
-e GH_PAT_DEMO="${{ secrets.GH_PAT_DEMO }}" \ | |
-e GITHUB_TOKEN="${{ secrets.GITHUB_TOKEN }}" \ | |
-e GH_PAT="${{ secrets.GH_PAT }}" \ | |
-e GITHUB_PAT="${{ secrets.GH_PAT }}" \ | |
local/quarto-reticulate:latest \ | |
/bin/sh -c $' | |
echo "=== Checking renv cache path ===" | |
ls -lah ${RENV_PATHS_CACHE} || echo "renv cache dir not found" | |
echo "=== Checking pip cache path ===" | |
ls -lah ${PIP_CACHE_DIR} || echo "pip cache dir not found" | |
echo "=== Package count in renv cache before restore ===" | |
Rscript -e \'cat(length(list.files(Sys.getenv("RENV_PATH"), recursive=TRUE)), "packages in cache\n")\' | |
# Restore R packages from project root | |
if [ -f "/project/renv.lock" ]; then | |
echo "=== Restoring R packages with renv ===" | |
Rscript -e \'renv::restore(project = "/project", lockfile="/project/renv.lock", library = Sys.getenv("RENV_PATH"), prompt = FALSE)\' | |
fi | |
echo "=== Package count in renv cache after restore ===" | |
Rscript -e \'cat(length(list.files(Sys.getenv("RENV_PATH"), recursive=TRUE)), "packages in cache\n")\' | |
# Restore Python packages into baked-in venv | |
if [ -f "/project/requirements.txt" ]; then | |
echo "=== Restoring Python packages into baked-in venv ===" | |
${VENV_PATH}/bin/pip install --cache-dir ${PIP_CACHE_DIR} -r /project/requirements.txt | |
fi | |
# Render + publish | |
cd /project | |
quarto render | |
COPY docs ./ | |
' --verbose | |
- name: Publish | |
uses: quarto-dev/quarto-actions/publish@v2 | |
with: | |
target: gh-pages | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |