Subject: Rendering Rmd via GitHub actions does not create floating table of contents
I’m trying to use GitHub Actions to render R Markdown (.Rmd
) files to .html
and .md
. I’d like the .html
file to have a floating table of contents. When I knit the .Rmd
file locally, the .html
file includes a floating table of contents. However, when I render the document to .html
with GitHub Actions, the .html
does not include a floating table of contents.
Here is my YAML header:
---
title: "INSERT TITLE"
author: "INSERT AUTHOR NAME"
date: '`r format(Sys.Date(), "%B %d, %Y")`'
output:
html_document:
toc: true
toc_float: true
number_sections: true
---
Here is the render_markdown.yml
file:
on:
push:
paths: ['**.Rmd']
name: render-rmarkdown
jobs:
render-rmarkdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up pandoc
uses: r-lib/actions/setup-pandoc@v2
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Install package dependencies
uses: r-lib/actions/setup-r-dependencies@v2
- name: Render Rmarkdown files and Commit Results
run: |
RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$'))
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f, output_format = c("html_document","github_document"))' ${RMD_PATH[*]}
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git add *[.Rmd/.md]
git add *[.Rmd/.html]
git commit -m 'Re-build Rmarkdown files' || echo "No changes to commit"
git push origin || echo "No changes to commit"
For a full reproducible example, you can see the GitHub repo here: https://github.com/isaactpetersen/markdowntest