Skip to content

Update to setup-r@v2 #32

Update to setup-r@v2

Update to setup-r@v2 #32

# Modified from
# - https://github.com/r-lib/actions/tree/master/examples#render-rmarkdown
# - https://github.com/gavinsimpson/gratia/blob/master/.github/workflows/readme-renderer.yaml
on:
push:
branches:
- main
- master
name: Render Readme
jobs:
render:
name: Render Readme
runs-on: macOS-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: r-lib/actions/setup-r@v2
- uses: r-lib/actions/setup-pandoc@v1
- name: Query dependencies
run: |
install.packages('remotes')
saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2)
shell: Rscript {0}
- name: Cache R packages
uses: actions/cache@v2
with:
path: ${{ env.R_LIBS_USER }}
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }}
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-
- name: Install rmarkdown, remotes, and the local package
run: |
install.packages("remotes")
remotes::install_local(".")
remotes::install_cran("rmarkdown")
remotes::install_cran("devtools")
remotes::install_cran("RCurl")
remotes::install_cran("kableExtra")
shell: Rscript {0}
- name: Render README.md using rmarkdown
run: Rscript -e 'rmarkdown::render("README.Rmd", output_format = "github_document")'
- name: Commit rendered README
run: |
git config --local user.email "actions@github.com"
git config --local user.name "GitHub Actions"
git add README.md README.html
git commit -m "Re-build README.md" || echo "No changes to commit"
git push origin master || echo "No changes to commit"
- name: Trigger pkgdown workflow
if: success()
uses: peter-evans/repository-dispatch@v1
with:
token: ${{ secrets.REPO_GHA_PAT }}
repository: ${{ github.repository }}
event-type: trigger-pkgdown-workflow
client-payload: '{"ref": "${{ github.ref }}", "sha": "${{ github.sha }}"}'