Skip to content

Commit b825030

Browse files
committed
Deploy to gh-pages
so that we can deploy to Connect Cloud
1 parent 1bce82e commit b825030

2 files changed

Lines changed: 26 additions & 34 deletions

File tree

.github/workflows/bookdown.yaml

Lines changed: 26 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:
@@ -43,19 +49,28 @@ jobs:
4349
run: sudo apt-get install -y ghostscript
4450

4551
- name: Cache bookdown results
46-
uses: actions/cache@v2
52+
uses: actions/cache@v4
4753
with:
4854
path: _bookdown_files
4955
key: bookdown-${{ hashFiles('**/*Rmd') }}
5056
restore-keys: bookdown-
5157

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
58+
- name: Build all book
6159
run: make all
60+
61+
- name: Deploy to gh-pages for Connect Cloud deploy
62+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
63+
uses: JamesIves/github-pages-deploy-action@v4
64+
with:
65+
branch: gh-pages
66+
folder: _book
67+
clean: true
68+
single-commit: true
69+
dry-run: ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.publish == 'false' || github.event.inputs.publish == false)) || false }}
70+
71+
- name: Upload book folder for debug
72+
if: failure()
73+
uses: actions/upload-artifact@main
74+
with:
75+
name: book-dir
76+
path: .

_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-
}

0 commit comments

Comments
 (0)