Skip to content

Render html

Render html #916

Workflow file for this run

# It was adapted by Candace Savonen for the OTTR_template https://github.com/jhudsl/OTTR_Template.
# This code was adapted by Carrie Wright to enable automated rendering of the site associated with this repository
# +---------------- minute (0 - 59)
# | +------------- hour (0 - 23)
# | | +---------- day of month (1 - 31)
# | | | +------- month (1 - 12)
# | | | | +---- day of week (0 - 6) (Sunday=0 or 7)
# | | | | |
# * * * * * command to be executed
name: Render html
on:
workflow_dispatch:
schedule:
- cron: "0 3 * * 0"
push:
branches:
- main
paths:
- '**.Rmd'
- collection.tsv
jobs:
build-collection:
name: Build Collection
uses: ./.github/workflows/build-collection.yml
with:
render-type: 'main'
repository: $GITHUB_REPOSITORY
secrets:
gh_pat: ${{ secrets.GH_PAT }}
render-main:
runs-on: ubuntu-latest
# install.packages("remotes") # in case we decide not to go with the container...
# remotes::install_cran("rmarkdown")
# remotes::install_deps(dependencies = TRUE)
needs: build-collection
container:
image: jhudsl/base_ottr:tidy4.3.2
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: checkout
uses: actions/checkout@v4
with:
# get the full repo
fetch-depth: 0
# use github PAT
token: ${{ secrets.GH_PAT }}
# We want a fresh run of the renders each time
- name: Delete old docs/*
run: rm -rf docs/*
# Now we want to render Rmd -> html
- name: Convert Rmd to html
id: bookdown
run: |
Rscript scripts/build.R
# Run TOC-less version
# Rendered content for Leanpub and Coursera is very similar.
# This job creates a shared scaffold for both.
- name: Run TOC-less version of render
id: tocless
run: Rscript -e "devtools::install_github('jhudsl/ottrpal', ref = remotes::github_pull('124'), upgrade = 'never'); ottrpal::render_without_toc()"
env:
GITHUB_PAT: ${{ secrets.gh_pat }}
# Commit the rendered site files - html files and site_libs files
- name: Commit rendered site files
run: |
git config --global --add safe.directory ${GITHUB_WORKSPACE}
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git config --global pull.ff true
git add . --force
git commit -m 'Render site' || echo "No changes to commit"
git pull --allow-unrelated-histories --strategy-option=ours
git push origin main || echo "No changes to push"