maj desc #154
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
on: | |
push: | |
branches: | |
- master | |
name: renderbook | |
jobs: | |
bookdown: | |
name: Render-Book | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAT: ${{ secrets.GH_PAT }} | |
steps: | |
- name : checkout | |
uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
- uses: r-lib/actions/setup-r@v2 | |
- uses: r-lib/actions/setup-pandoc@v2 | |
- name: Get R version | |
id: get-r-version | |
run: | | |
echo "::set-output name=version::$(Rscript -e 'cat(as.character(getRversion()))')" | |
shell: bash | |
- name: Cache R packages | |
uses: actions/cache@v1 | |
with: | |
path: ${{ env.R_LIBS_USER }} | |
key: ${{ runner.os }}-${{ steps.get-r-version.outputs.version }}-3- | |
- name: Cache bookdown results | |
uses: actions/cache@v1 | |
with: | |
path: _bookdown_files | |
key: bookdown-2-${{ hashFiles('**/*Rmd') }} | |
restore-keys: bookdown-2- | |
- name: Install pak | |
run: | | |
install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") | |
shell: Rscript {0} | |
- name: Install dependencies | |
run: | | |
pak::local_install_dev_deps() | |
tinytex::install_tinytex() | |
shell: Rscript {0} | |
- name: Render Book | |
run: | | |
bookdown::render_book("index.Rmd", "bookdown::bs4_book") | |
bookdown::render_book("index.Rmd", "bookdown::pdf_book") | |
shell: Rscript {0} | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: _book | |
path: _book/ | |
# Need to first create an empty gh-pages branch | |
# see https://pkgdown.r-lib.org/reference/deploy_site_github.html | |
# and also add secrets for a GH_PAT and EMAIL to the repository | |
# gh-action from Cecilapp/GitHub-Pages-deploy | |
checkout-and-deploy: | |
runs-on: ubuntu-latest | |
needs: bookdown | |
steps: | |
- name: Checkout | |
uses: actions/checkout@master | |
- name: Download artifact | |
uses: actions/download-artifact@v1 | |
with: | |
# Artifact name | |
name: _book # optional | |
# Destination path | |
path: _book # optional | |
- name: Deploy to GitHub Pages | |
uses: Cecilapp/GitHub-Pages-deploy@v3 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
with: | |
email: ${{ secrets.EMAIL }} | |
build_dir: _book | |