Skip to content

Add github action to knit Rmd #3

Add github action to knit Rmd

Add github action to knit Rmd #3

Workflow file for this run

name: Knit Rmd Files
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
jobs:
knit:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up R
uses: r-lib/actions/setup-r@v2
- name: Install dependencies
uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: |
any::rmarkdown
any::knitr
install-pandoc: true
-
run: |
Rscript -e 'install.packages(c("rmarkdown", "knitr"))'
- name: Find and knit Rmd files
run: |
Rscript -e '
rmd_files <- list.files(pattern = "\\.Rmd$", recursive = TRUE)
for (file in rmd_files) {
rmarkdown::render(file)
}
'
- name: Commit changes
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Knit Rmd files" || echo "No changes to commit"
- name: Push changes
uses: ad-m/[email protected]
with:
branch: ${{ github.head_ref }}