I expected usethis::use_github_action("render-readme.yaml")
to generate a general workflow for anyone to use "out of the box". Instead I get a workflow that specifically renders this file: https://github.com/r-lib/actions/blob/master/examples/README.Rmd.
Am I supposed to edit the render-readme.yaml? Or is this a "bug".
What works for me is something like this:
on:
push:
paths:
- README.Rmd
name: Render README
jobs:
render:
name: Render README
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-pandoc@v1
- name: Install rmarkdown
run: Rscript -e 'install.packages("rmarkdown")'
- name: Render README
run: Rscript -e 'rmarkdown::render("README.Rmd")'
- name: Commit results
run: |
git add README.md && git commit README.md -m 'Re-build README.Rmd' || echo "No changes to commit"
git push https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/${{github.repository}}.git HEAD:${{ github.ref }} || echo "No changes to commit"
My edit:
- Removes references to the directory examples/;
- adds
git add
to account for the case when the repo doesn't have a README.md already; - adds
output_format = "github_document"
to account for the case when README.Rmd lacks such specification in the yaml header.
I'm new to GitHub actions. Can you help me improve this?