Skip to content

Commit a8fb75e

Browse files
committed
Add github action to knit Rmd
1 parent 00b8c2a commit a8fb75e

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

.github/workflows/knit-rmd.yaml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Knit Rmd Files
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
knit:
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up R
22+
uses: r-lib/actions/setup-r@v2
23+
24+
- name: Install dependencies
25+
run: |
26+
Rscript -e 'install.packages(c("rmarkdown", "knitr"))'
27+
28+
- name: Find and knit Rmd files
29+
run: |
30+
Rscript -e '
31+
rmd_files <- list.files(pattern = "\\.Rmd$", recursive = TRUE)
32+
for (file in rmd_files) {
33+
rmarkdown::render(file)
34+
}
35+
'
36+
37+
- name: Commit changes
38+
run: |
39+
git config --global user.name "github-actions[bot]"
40+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
41+
git add -A
42+
git commit -m "Knit Rmd files" || echo "No changes to commit"
43+
44+
- name: Push changes
45+
uses: ad-m/[email protected]
46+
with:
47+
branch: ${{ github.head_ref }}

0 commit comments

Comments
 (0)