Skip to content

Commit 61cdd32

Browse files
authored
Deploy to gh-pages (#112)
1 parent 1bce82e commit 61cdd32

File tree

4 files changed

+29
-37
lines changed

4 files changed

+29
-37
lines changed

.github/workflows/bookdown.yaml

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ on:
66
pull_request:
77
branches: [main, master]
88
workflow_dispatch:
9+
inputs:
10+
publish:
11+
description: 'publish the book to github pages for connect cloud deployment'
12+
required: false
13+
default: false
14+
type: boolean
915

1016
name: bookdown
1117

@@ -17,7 +23,7 @@ jobs:
1723
R_KNITR_OPTIONS: "knitr.chunk.tidy=TRUE"
1824
steps:
1925
- name: Checkout Repo
20-
uses: actions/checkout@v2
26+
uses: actions/checkout@v4
2127

2228
- uses: r-lib/actions/setup-pandoc@v2
2329
with:
@@ -37,25 +43,35 @@ jobs:
3743
- uses: r-lib/actions/setup-r-dependencies@v2
3844
with:
3945
needs: deploy
46+
extra-packages: github::yihui/knitr
4047

4148
- name: Install missing system dependencies
4249
if: runner.os == 'Linux'
4350
run: sudo apt-get install -y ghostscript
4451

4552
- name: Cache bookdown results
46-
uses: actions/cache@v2
53+
uses: actions/cache@v4
4754
with:
4855
path: _bookdown_files
4956
key: bookdown-${{ hashFiles('**/*Rmd') }}
5057
restore-keys: bookdown-
5158

52-
- name: Build Gitbook
53-
if: github.event_name == 'pull_request'
54-
run: make gitbook
55-
56-
- name: Build and Deploy all book
57-
if: github.event_name == 'push'
58-
env:
59-
CONNECT_API_KEY: ${{ secrets.RSC_BOOKDOWN_ORG_TOKEN }}
60-
CONTENT_ID: c4506062-503b-4747-bcd8-490dd76620cb
59+
- name: Build all book
6160
run: make all
61+
62+
- name: Deploy to gh-pages for Connect Cloud deploy
63+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
64+
uses: JamesIves/github-pages-deploy-action@v4
65+
with:
66+
branch: gh-pages
67+
folder: _book
68+
clean: true
69+
single-commit: true
70+
dry-run: ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.publish == 'false' || github.event.inputs.publish == false)) || false }}
71+
72+
- name: Upload book folder for debug
73+
if: failure()
74+
uses: actions/upload-artifact@main
75+
with:
76+
name: book-dir
77+
path: .

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Imports:
2323
servr,
2424
shiny,
2525
tufte,
26-
webshot,
26+
webshot2,
2727
xaringan,
2828
sigma
2929
Remotes:

_render.R

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,3 @@ for (fmt in formats) {
99
res = xfun::Rscript(c('-e', shQuote(cmd)))
1010
if (res != 0) stop('Failed to compile the book to ', fmt)
1111
}
12-
13-
# When several format are rendered, usually when make all is called,
14-
# then we publish everything to bookdown.org
15-
if (length(formats) > 1) {
16-
message(">> Publishing Books")
17-
if (!is.na(Sys.getenv("CI", NA))) {
18-
xfun::pkg_load2("rsconnect")
19-
# On CI connect to server, using API KEY and deploy using appId
20-
rsconnect::addConnectServer('https://bookdown.org', 'bookdown.org')
21-
rsconnect::connectApiUser(
22-
account = 'GHA', server = 'bookdown.org',
23-
apiKey = Sys.getenv('CONNECT_API_KEY')
24-
)
25-
rsconnect::deploySite(
26-
appId = Sys.getenv('CONTENT_ID'),
27-
server = 'bookdown.org',
28-
render = 'none', logLevel = 'verbose',
29-
forceUpdate = TRUE)
30-
} else if (Sys.getenv('USER') == 'yihui') {
31-
# for local deployment when rsconnect/ is available
32-
bookdown::publish_book('rmarkdown', server = 'bookdown.org', render = 'none')
33-
}
34-
}

index.Rmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,7 @@ options(bookdown.post.latex = function(x) {
5353
x
5454
})
5555
56-
knitr::opts_chunk$set(webshot = "webshot")
57-
webshot::install_phantomjs()
56+
knitr::opts_chunk$set(webshot = "webshot2")
5857
```
5958

6059
# Preface {-}

0 commit comments

Comments
 (0)