01 Build and Deploy Site #34
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: "01 Build and Deploy Site" | |
on: | |
push: | |
branches: | |
- main | |
- master | |
schedule: | |
- cron: '0 0 * * 2' | |
workflow_dispatch: | |
inputs: | |
name: | |
description: 'Who triggered this build?' | |
required: true | |
default: 'Maintainer (via GitHub)' | |
reset: | |
description: 'Reset cached markdown files' | |
required: false | |
default: false | |
type: boolean | |
jobs: | |
full-build: | |
name: "Build Full Site" | |
# 2024-10-01: ubuntu-latest is now 24.04 and R is not installed by default in the runner image | |
# pin to 22.04 for now | |
runs-on: ubuntu-22.04 | |
permissions: | |
checks: write | |
contents: write | |
pages: write | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
RENV_PATHS_ROOT: ~/.local/share/renv/ | |
steps: | |
- name: "Checkout Lesson" | |
uses: actions/checkout@v4 | |
- name: "Set up R" | |
uses: r-lib/actions/setup-r@v2 | |
with: | |
use-public-rspm: true | |
install-r: false | |
- name: "Set up Pandoc" | |
uses: r-lib/actions/setup-pandoc@v2 | |
- name: "Setup Lesson Engine" | |
uses: carpentries/actions/setup-sandpaper@main | |
with: | |
cache-version: ${{ secrets.CACHE_VERSION }} | |
- name: "Setup Package Cache" | |
uses: carpentries/actions/setup-lesson-deps@main | |
with: | |
cache-version: ${{ secrets.CACHE_VERSION }} | |
- name: "Deploy Site" | |
run: | | |
reset <- "${{ github.event.inputs.reset }}" == "true" | |
sandpaper::package_cache_trigger(TRUE) | |
sandpaper:::ci_deploy(reset = reset) | |
shell: Rscript {0} | |
- name: "Checkout gh-pages branch" | |
run: | | |
git fetch origin | |
git checkout gh-pages | |
- name: "Modify .html" | |
run: | | |
find . -name "*.html" -exec sh -c 'echo "<script src="files/additional.js" type="text/javascript"></script>" >> "$1"' _ {} \; | |
- name: "Commit and Push Changes" | |
run: | | |
git config user.name "github-actions[bot]" | |
git config user.email "github-actions[bot]@users.noreply.github.com" | |
git add *.html | |
git commit -m "Add a new line to index.html via GitHub Actions" | |
git push origin gh-pages |