-
Notifications
You must be signed in to change notification settings - Fork 1
95 lines (76 loc) · 2.41 KB
/
deploy_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
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 "{name}=version::$(Rscript -e 'cat(as.character(getRversion()))')" >> $GITHUB_OUTPUT
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@v4
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