Problem with GitHub Action - YAML Header parsing error.

I have two repos that I use GitHub actions to render markdown files into books. Below is the YAML language we use in both repos. When run on one repo, it works fine. When run on the other, it crashes:

'on:
pull_request:
branches: [ gh-pages ]
types: [ closed ]

name: renderbook

env:
ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true'

jobs:
bookdown:
name: Render-Book
runs-on: macOS-latest
steps:
- uses: actions/checkout@v4
with:
ref: gh-pages
- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-pandoc@v2
- name: Install rmarkdown
run: Rscript -e 'install.packages(c("rmarkdown","bookdown","HelpersMG","readr","digest"))'

  - uses: r-lib/actions/setup-tinytex@v2
  - name : install tinytex
    run: tlmgr --version

  - name: Render Book
    run: |
         Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::gitbook", output_dir="docs")'
  - uses: actions/upload-artifact@v4
    with:
      name: docs
      path: docs/

deploy to gh pages yml

build-and-deploy:
runs-on: ubuntu-latest
needs: bookdown
steps:
- name: Checkout :bellhop_bell:
uses: actions/checkout@v4 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
with:
persist-credentials: false

  - name: Download Artifacts ๐Ÿ”ป # The built project is downloaded into the 'site' folder.
    uses: actions/download-artifact@v1
    with:
      name: docs
      
  - name: Deploy ๐Ÿš€
    uses: JamesIves/github-pages-deploy-action@releases/v3
    with:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      BRANCH: gh-pages # The branch the action should deploy to.
      FOLDER: docs
      TARGET_FOLDER: docs # The folder the action should deploy.
      CLEAN: true
      PRESERVE: true'

Below are the errors that are generated. Appears to be an issue parsing the YAML header. The YAML header is correct. So, we are looking for ideas on what is wrong. Thank you in advance!

ERRORS

///////////////////////////////////


//////////////////////////////////

And the 'index.Rmd' file header:


title: "Team PSD Manual"
author: "Team PSD"
date: "r Sys.Date()"
link-citations: yes
preview: yes
site: bookdown::bookdown_site
description: This is the Team PSD one stop shop.

Locally, on your machine, are you able to render that bookdown project?

1 Like

Yeah, this does not seem like an error with GitHub Actions,. but an error in your bookdown YAML.

@ Everyone - thank you for the responses!

  1. I have not tried to render on my desktop. Not sure how to do that but will figure that out and try it.

  2. Regarding the index.Rmd file that is throwing the parsing error, I have checked, and triple checked the header structure. I have even recreated the file and that has not resolved the error.

The header structure is as follows:

---
title: "Team PSD Manual"
author: "Team PSD"
date: "`r Sys.Date()`"
link-citations: yes
preview: yes
site: bookdown::bookdown_site
description: This is the Team PSD one stop shop.
---

Also - I am running this exact action on another repository and it works great! Go figure.

Again, I think the YAML error is in an Rmd file, not in the YAML of the GHA workflow. (If there is an error in the YAML of the workflow, GitHub can't even run it.)

Is your repository public?

@Gabor yes, it is lzim/teampsd

lzim/teampsd: Team PSD is using GitHub, R and RMarkdown as part of our free and open science workflow.

Also, I ran an experiment yesterday where I removed all the content of the index.Rmd file and hand-typed in the YAML header. Still threw the same error 64.

Can you also point to a failing build?

Yes. This is the run for the simplified 'index.Rmd' file.

Feature gh pages test 2 ยท lzim/teampsd@2bdbcf1 (github.com)

You need to leave an empty line before and after the

---

separators, otherwise Pandoc thinks they denote a YAML header. E.g. here:

1 Like

Ok, let me give that a try.

@gabor Unfortunately, that didn't work. I entered a line at line 1 in the 'index.Rmd' file and it behaved with the same error.

I am not sure what you mean. You need to fix that line I referred to, line 65 in 6.6_produce_patient_and_provider_enrollment_tables_for_progress_reports.md. Add an empty line after the

---

separator line. Plus if you have similar separators elsewhere fix those as well.

In any case, this has nothing to do with GitHub Actions, and I suggest you run bookdown of your laptop locally, it is much simpler to debug it.

This topic was automatically closed after 45 days. New replies are no longer allowed.


If you have a query related to it or one of the replies, start a new topic and refer back with a link.