Render trainR post #10933
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
# 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: | |
branches: master | |
schedule: | |
- cron: '0 5-22/6 * * *' | |
name: Render trainR post | |
jobs: | |
render: | |
name: Render the trainR post | |
runs-on: macos-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} | |
NRE: ${{ secrets.NRE }} | |
steps: | |
- name: Checkout repo | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- uses: r-lib/actions/setup-r@v2 | |
- name: OS dependencies | |
run: | | |
brew install openssl | |
brew install libgit2 | |
- name: Query dependencies | |
run: | | |
install.packages(c("remotes", "blogdown")) | |
remotes::install_cran("rmarkdown") | |
remotes::install_github("villegar/trainR", "dev") | |
writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") | |
shell: Rscript {0} | |
- name: Cache R packages | |
uses: actions/cache@v3 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- | |
restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- | |
- name: Render Rmd | |
run: | | |
# list up Rmd files | |
# rmd <- list.files("content/post/2021-02-08-trainr-an-interface-to-the-national-rail-enquiries-systems", "\\.Rmd$", recursive = TRUE, full.names = TRUE) | |
# list up md files | |
# md_files <- sub("\\.Rmd$", ".md", rmd) | |
# names(md_files) <- rmd | |
# knitr::knit(input = rmd[1], output = md_files[1], encoding = "UTF-8") | |
knitr::knit(input = "content/post/2021-02-08-trainr-an-interface-to-the-nre-systems.en-uk.Rmd", | |
output = "content/post/2021-02-08-trainr-an-interface-to-the-nre-systems.en-uk.md", | |
encoding = "UTF-8") | |
# Rscript -e 'rmarkdown::render("content/post/2021-02-08-trainr-an-interface-to-the-national-rail-enquiries-systems/index.en-uk.Rmd", blogdown::html_page())' | |
shell: Rscript {0} | |
- name: Commit results | |
run: | | |
git config --local user.name "$GITHUB_ACTOR" | |
git config --local user.email "[email protected]" | |
git commit content/post/2021-02-08-trainr-an-interface-to-the-nre-systems.en-uk.md -m 'Re-build trainR post' || echo "No changes to commit" | |
git push origin || echo "No changes to commit" |