Add github action to knit Rmd #5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: Setup pandoc | |
uses: r-lib/actions/setup-pandoc@v2 | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up R | |
uses: r-lib/actions/setup-r@v2 | |
- name: Install dependencies | |
run: | | |
Rscript -e 'install.packages(c("rmarkdown", "knitr")); remotes::install_github("SAFEHR-data/omopcept")' | |
- 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 }} |