quarto #1057
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: renderbook | |
on: | |
push: | |
branches: | |
- master | |
- develop | |
pull_request: | |
branches: | |
- master | |
repository_dispatch: | |
types: [quarto] | |
env: | |
BRANCH: ${{ github.event.client_payload.branch }} | |
REPO: ${{ github.event.client_payload.repo }} | |
GH_USER: 'RRC_GHA' # must be set | |
jobs: | |
quarto: | |
if: github.event.action == 'quarto' || github.event_name == 'push' | |
runs-on: ubuntu-latest | |
# commit book build to RRC repo | |
permissions: | |
contents: write | |
env: | |
R_REMOTES_NO_ERRORS_FROM_WARNINGS: true | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- name: Check name of branch from nceas-training | |
run: | | |
echo $BRANCH | |
- uses: actions/checkout@v3 | |
with: | |
submodules: true | |
- name: Checkout repo from branch | |
uses: actions/checkout@v3 | |
with: | |
repository: NCEAS/${{ env.REPO }} | |
ref: "${{ env.BRANCH }}" | |
path: ${{ env.REPO }} | |
- uses: Homebrew/actions/setup-homebrew@master | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' # Version range or exact version of a Python version to use, using SemVer's version range syntax | |
- name: System libraries | |
run: | | |
sudo apt update | |
sudo apt-get install -y libjq-dev libudunits2-dev libpoppler-cpp-dev libgdal-dev gdal-bin libproj-dev proj-data proj-bin libgeos-dev librdf0-dev libharfbuzz-dev libspatialindex-dev libfribidi-dev | |
- name: Setup R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Restore R package cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
${{ env.R_LIBS_USER }}/* | |
key: ${{ runner.os }}-build-R-${{ hashFiles('**/DESCRIPTION') }} | |
- name: Install R dependencies | |
run: | | |
options(repos = c(REPO_NAME = "https://packagemanager.posit.co/cran/__linux__/jammy/latest")) | |
install.packages(c("remotes")) | |
remotes::install_deps() | |
shell: Rscript {0} | |
- name: Install dependencies based on branch | |
run: | | |
if [[ "${{ env.REPO }}" == "nceas-training" ]]; then | |
echo "Installing R dependencies" | |
R -e 'remotes::install_deps(pkgdir="nceas-training/materials")' | |
elif [[ "${{ env.REPO }}" == "scalable-computing-course" ]]; then | |
echo "Installing python dependencies" | |
python3 -m pip install --use-deprecated=legacy-resolver -r scalable-computing-course/requirements.txt | |
fi | |
- name: Install pandoc | |
run: | | |
brew install pandoc | |
- name: Install hugo | |
run: | | |
Rscript -e 'blogdown::install_hugo(version = "0.59.0")' | |
- name: Build blogdown site | |
run: | | |
Rscript -e 'blogdown::build_site()' | |
touch public/.nojekyll | |
cp CNAME public/CNAME | |
- name: Install Quarto | |
uses: quarto-dev/quarto-actions/setup@v2 | |
with: | |
tinytex: true # installs tinytex | |
#- name: Build training materials scalable | |
# run: sh _build_quarto.sh | |
- name: Render Quarto training materials | |
run: | | |
if [[ "${{ env.REPO }}" == "nceas-training" ]]; then | |
echo "Rendering nceas-training" | |
quarto render "nceas-training/materials" | |
elif [[ "${{ env.REPO }}" == "scalable-computing-course" ]]; then | |
echo "Rendering scalable-computing-course" | |
quarto render "scalable-computing-course" | |
fi | |
- name: Move training materials to public/$BRANCH | |
run: | | |
mkdir -p public/$BRANCH # make dir if none exists | |
echo $(ls public) | |
if [[ "${{ env.REPO }}" == "nceas-training" ]]; then | |
echo $(ls ${{ env.REPO }}/materials) | |
cp -R '${{ env.REPO }}/materials/_book'/* public/$BRANCH/ | |
elif [[ "${{ env.REPO }}" == "scalable-computing-course" ]]; then | |
echo $(ls ${{ env.REPO }}) | |
cp -R '${{ env.REPO }}/_book'/* public/$BRANCH/ | |
fi | |
- name: Commit build | |
run: | | |
git config --global user.name $GH_USER | |
git config --global user.email "[email protected]" | |
git add public/$BRANCH | |
git commit -m "Create automated build" | |
git push | |
- name: Deploy to GitHub Pages | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages # branch the action should deploy to | |
folder: public/ # folder the action should deploy |