Updates via chatgpt #418
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 | |
| 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 & publish with cached renv/pip | |
| 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=/root/.local/share/renv \ | |
| -e PIP_CACHE_DIR=/root/.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 ' | |
| set -e | |
| # R deps from renv in setup/ | |
| if [ -f "/project/renv.lock" ]; then | |
| Rscript -e "renv::restore(project = '/project', prompt = FALSE)" | |
| fi | |
| # Python deps | |
| if [ -f "/project/setup/requirements.txt" ]; then | |
| python3 -m venv /root/.virtualenvs/venv | |
| /root/.virtualenvs/venv/bin/pip install --upgrade pip | |
| /root/.virtualenvs/venv/bin/pip install --cache-dir ${PIP_CACHE_DIR} -r /project/setup/requirements.txt | |
| export PATH=/root/.virtualenvs/venv/bin:$PATH | |
| fi | |
| # Quarto | |
| cd /project | |
| quarto render && quarto publish | |
| ' |