-
Notifications
You must be signed in to change notification settings - Fork 17
107 lines (88 loc) · 3.12 KB
/
bookdown.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
on:
push:
branches:
- master
pull_request:
branches:
- master
name: booklet
jobs:
bookdown:
name: build-bookdown
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
RENV_PATHS_ROOT: ~/.local/share/renv
steps:
- name: Checkout repo
uses: actions/checkout@v3
#- name: Setup upterm session
#uses: lhotari/action-upterm@v1
- name: Setup R
uses: r-lib/actions/setup-r@v2
- name: Install pandoc
uses: r-lib/actions/setup-pandoc@v2
- name: Install tinyTeX
uses: r-lib/actions/setup-tinytex@v2
- name: Install system dependencies
run: |
sudo apt install -y curl libcurl4-doc libcurl4-openssl-dev libmagick++-dev libpoppler-cpp-dev texlive-extra-utils ghostscript
- name: Install rmarkdown, bookdown and sysfonts
run: Rscript -e 'install.packages(c("sysfonts","rmarkdown","bookdown"))'
- name: Cache R packages
uses: actions/cache@v3
with:
path: ${{ env.RENV_PATHS_ROOT }}
key: ${{ runner.os }}-renv-${{ hashFiles('**/renv.lock') }}
restore-keys: |
${{ runner.os }}-renv-
- name: Restore R packages
shell: Rscript {0}
run: |
if (!requireNamespace("renv", quietly = TRUE)) install.packages("renv")
renv::restore()
- name: Cache bookdown results
uses: actions/cache@v3
with:
path: _bookdown_files
key: bookdown-2-${{ hashFiles('**/*Rmd') }}
restore-keys: bookdown-2-
- name: Render book HTML
run: |
Rscript -e 'bookdown::clean_book(TRUE)'
Rscript -e 'bookdown::render_book("index.Rmd", quiet = TRUE)'
- name: Render book PDF
run: |
Rscript -e 'bookdown::render_book("index.Rmd", "bookdown::pdf_book")'
- uses: actions/upload-artifact@v3
with:
name: _handbook
path: _handbook/
# 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 https://github.com/Cecilapp/GitHub-Pages-deploy
checkout-and-deploy:
runs-on: ubuntu-latest
needs: bookdown
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download Artifact
uses: actions/download-artifact@v3
with:
# Artifact name
name: _handbook # optional
# Destination path
path: _handbook # optional
- name: Abbreviate Git SHA
run: echo "GITHUB_SHA_SHORT=$(git rev-parse --short $GITHUB_SHA)" >> $GITHUB_ENV
- name: Deploy to GitHub Pages
uses: Cecilapp/GitHub-Pages-deploy@v3
if: github.event_name != 'pull_request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
email: ${{ secrets.EMAIL }} # must be a GitHub-verified email
build_dir: _handbook/ # "_site/" by default
commit_message: Update book via ${{ env.GITHUB_SHA_SHORT }}