Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions .github/workflows/bookdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
pull_request:
branches: [main, master]
workflow_dispatch:
inputs:
publish:
description: 'publish the book to github pages for connect cloud deployment'
required: false
default: false
type: boolean

name: bookdown

Expand All @@ -17,7 +23,7 @@ jobs:
R_KNITR_OPTIONS: "knitr.chunk.tidy=TRUE"
steps:
- name: Checkout Repo
uses: actions/checkout@v2
uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2
with:
Expand All @@ -37,25 +43,35 @@ jobs:
- uses: r-lib/actions/setup-r-dependencies@v2
with:
needs: deploy
extra-packages: github::yihui/knitr

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

- name: Cache bookdown results
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: _bookdown_files
key: bookdown-${{ hashFiles('**/*Rmd') }}
restore-keys: bookdown-

- name: Build Gitbook
if: github.event_name == 'pull_request'
run: make gitbook

- name: Build and Deploy all book
if: github.event_name == 'push'
env:
CONNECT_API_KEY: ${{ secrets.RSC_BOOKDOWN_ORG_TOKEN }}
CONTENT_ID: c4506062-503b-4747-bcd8-490dd76620cb
- name: Build all book
run: make all

- name: Deploy to gh-pages for Connect Cloud deploy
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: _book
clean: true
single-commit: true
dry-run: ${{ (github.event_name == 'workflow_dispatch' && (github.event.inputs.publish == 'false' || github.event.inputs.publish == false)) || false }}

- name: Upload book folder for debug
if: failure()
uses: actions/upload-artifact@main
with:
name: book-dir
path: .
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Imports:
servr,
shiny,
tufte,
webshot,
webshot2,
xaringan,
sigma
Remotes:
Expand Down
23 changes: 0 additions & 23 deletions _render.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,3 @@ for (fmt in formats) {
res = xfun::Rscript(c('-e', shQuote(cmd)))
if (res != 0) stop('Failed to compile the book to ', fmt)
}

# When several format are rendered, usually when make all is called,
# then we publish everything to bookdown.org
if (length(formats) > 1) {
message(">> Publishing Books")
if (!is.na(Sys.getenv("CI", NA))) {
xfun::pkg_load2("rsconnect")
# On CI connect to server, using API KEY and deploy using appId
rsconnect::addConnectServer('https://bookdown.org', 'bookdown.org')
rsconnect::connectApiUser(
account = 'GHA', server = 'bookdown.org',
apiKey = Sys.getenv('CONNECT_API_KEY')
)
rsconnect::deploySite(
appId = Sys.getenv('CONTENT_ID'),
server = 'bookdown.org',
render = 'none', logLevel = 'verbose',
forceUpdate = TRUE)
} else if (Sys.getenv('USER') == 'yihui') {
# for local deployment when rsconnect/ is available
bookdown::publish_book('rmarkdown', server = 'bookdown.org', render = 'none')
}
}
3 changes: 1 addition & 2 deletions index.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ options(bookdown.post.latex = function(x) {
x
})

knitr::opts_chunk$set(webshot = "webshot")
webshot::install_phantomjs()
knitr::opts_chunk$set(webshot = "webshot2")
```

# Preface {-}
Expand Down
Loading