Skip to content

Commit 2095921

Browse files
committed
Full book is now deployed to gh-pages to be deployed to Connect cloud from there as a static book
1 parent 86e3631 commit 2095921

File tree

2 files changed

+9
-50
lines changed

2 files changed

+9
-50
lines changed

.github/workflows/Book.yaml

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,11 @@ on:
2121
- '.github/workflows/Book.yaml'
2222
workflow_dispatch:
2323
inputs:
24-
ghpages:
25-
description: 'Build gitbook with pandoc devel and deploy gitbook to gh-page for checking differences'
24+
publish:
25+
description: 'publish the book to github pages for connect cloud deployment'
2626
required: false
27-
default: true
27+
default: false
28+
type: boolean
2829

2930
name: Build and deploy book
3031

@@ -45,17 +46,15 @@ jobs:
4546

4647
steps:
4748
- name: Checkout Repo
48-
uses: actions/checkout@v4
49+
uses: actions/checkout@v6
4950

5051
- name: Install R
5152
uses: r-lib/actions/setup-r@v2
5253

5354
- name: Install Pandoc
5455
uses: r-lib/actions/setup-pandoc@v2
5556
with:
56-
# install nightly when checking on gh-pages
57-
pandoc-version: ${{ github.event.inputs.ghpages && 'nightly' || '3.8' }}
58-
token: ${{ secrets.GITHUB_TOKEN }}
57+
pandoc-version: latest
5958

6059
- name: Install TinyTeX
6160
uses: r-lib/actions/setup-tinytex@v2
@@ -97,18 +96,14 @@ jobs:
9796
CONTENT_ID: 3
9897
run: make -C inst/examples all
9998

100-
- name: Build Gitbook only
101-
env:
102-
DEPLOY_GH_PAGES: ${{ github.event.inputs.ghpages }}
103-
if: github.event_name == 'workflow_dispatch'
104-
run: make -C inst/examples gitbook
105-
10699
- name: Deploy Gitbook to gh-pages
107-
if: github.event_name == 'workflow_dispatch' && github.event.inputs.ghpages
100+
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' &&
108101
uses: JamesIves/github-pages-deploy-action@v4
109102
with:
110103
branch: gh-pages
111104
folder: inst/examples/_book
105+
clean: true
106+
dry-run: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.publish) || false }}
112107

113108
- name: Upload book folder for debug
114109
if: failure()

inst/examples/_render.R

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
quiet = "--quiet" %in% commandArgs(FALSE)
22
formats = commandArgs(TRUE)
3-
# travis is still use for github page deployment
4-
# TODO: Remove github page deployment
5-
ghpages = identical(Sys.getenv("DEPLOY_GH_PAGES", NA), "true")
63

74

85
src = (function() {
@@ -34,44 +31,11 @@ for (f in list.files('_book', '[.]html$', full.names = TRUE)) {
3431
x = readLines(f)
3532

3633
if (length(i <- grep('^\\s*<body>\\s*$', x)) == 0) next
37-
# patch HTML files when published to gh-pages to redirect to bookdown.org
38-
if (ghpages) x[i[1]] = '<body onload="window.location = \'https://bookdown.org/yihui\'+location.pathname">'
3934
i = grep('<i class="fa fa-circle-o-notch fa-spin"></i><a href="./">.+</a>', x)[1]
4035
# shorter title on the toolbar
4136
if (!is.na(i)) x[i] = gsub('bookdown: ', '', x[i], fixed = TRUE)
42-
# Remove some lines when published to gh-pages
43-
if (ghpages) {
44-
i = c(
45-
grep('&lt;bytecode: 0x[0-9a-f]+&gt;$', x),
46-
grep('^\\s*<meta name="generator" content="bookdown [.0-9]+ and GitBook [.0-9]+" />$', x),
47-
grep('^<meta name="date" content="[-0-9]+" />$', x)
48-
)
49-
if (length(i)) x = x[-i]
50-
}
5137

5238
writeLines(x, f)
5339
}
5440

55-
# When several format are rendered, usually when make all is called,
56-
# then we publish everything to bookdown.org
57-
if (length(formats) > 1 && !ghpages) {
58-
message(">> Publishing Books")
59-
if (!is.na(Sys.getenv("CI", NA))) {
60-
# On CI connect to server, using API KEY and deploy using appId
61-
rsconnect::addServer('https://bookdown.org', 'bookdown.org')
62-
rsconnect::connectApiUser(
63-
account = 'GHA', server = 'bookdown.org',
64-
apiKey = Sys.getenv('CONNECT_API_KEY')
65-
)
66-
rsconnect::deploySite(
67-
appId = Sys.getenv('CONTENT_ID'),
68-
server = 'bookdown.org',
69-
render = 'none', logLevel = 'verbose',
70-
forceUpdate = TRUE)
71-
} else {
72-
# for local deployment when rsconnect/ is available
73-
bookdown::publish_book('bookdown', server = 'bookdown.org', render = 'none')
74-
}
75-
}
76-
7741
setwd(owd)

0 commit comments

Comments
 (0)