Skip to content

Commit

Permalink
Update render-rmarkdown.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmackintosh authored Nov 22, 2024
1 parent 6c08f5a commit 2b0c2d5
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions .github/workflows/render-rmarkdown.yaml
Original file line number Diff line number Diff line change
@@ -1,45 +1,36 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
on:
push:
paths:
- '**.Rmd'
paths: ['**.Rmd']

name: render-rmarkdown.yaml

permissions: read-all

jobs:
build:
runs-on: macOS-latest
render-rmarkdown:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup R
uses: r-lib/actions/setup-r@v1

- name: Install pandoc
run: |
brew install pandoc
- uses: r-lib/actions/setup-pandoc@v2

- name: Cache Renv packages
uses: actions/cache@v2
with:
path: $HOME/.local/share/renv
key: r-${{ hashFiles('renv.lock') }}
restore-keys: r-
- uses: r-lib/actions/setup-r@v2

- name: Install packages
run: |
R -e 'install.packages("renv")'
R -e 'renv::restore()'
- uses: r-lib/actions/setup-renv@v2

- name: Render Rmarkdown files
- name: Render Rmarkdown files and Commit Results
run: |
RMD_PATH=($(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep '[.]Rmd$'))
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]}
- name: Commit results
run: |
Rscript -e 'for (f in commandArgs(TRUE)) if (file.exists(f)) rmarkdown::render(f)' ${RMD_PATH[*]}
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "$GITHUB_ACTOR@users.noreply.github.com"
git commit ${RMD_PATH[*]/.Rmd/.md} -m 'Re-build Rmarkdown files' || echo "No changes to commit"
Expand Down

0 comments on commit 2b0c2d5

Please sign in to comment.