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
39 changes: 20 additions & 19 deletions .github/workflows/bookdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ on:
paths:
- 'docs/**'
- '.github/workflows/bookdown.yaml'
pull_request:
branches: [main, master]
paths:
- 'docs/**'
- '.github/workflows/bookdown.yaml'
workflow_dispatch:
inputs:
publish:
description: 'publish the book to github pages for connect cloud deployment'
required: false
default: false
type: boolean

name: Build and deploy book

Expand Down Expand Up @@ -51,28 +62,18 @@ jobs:
key: bookdown-1-${{ hashFiles('docs/*Rmd') }}
restore-keys: bookdown-1-

- name: Build and Deploy all book
if: github.event_name == 'push'
env:
CONNECT_API_KEY: ${{ secrets.RSC_BOOKDOWN_ORG_TOKEN }}
CONTENT_ID: 463
- name: Build all book
run: make -C docs all

- uses: actions/github-script@v3
env:
URL: https://bookdown.org/yihui/blogdown
- name: Deploy Gitbook to gh-pages
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
uses: JamesIves/github-pages-deploy-action@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: "success",
target_url: "${{ env.URL}}",
description: "Book deployed!",
context: "bookdown.org"
})
branch: gh-pages
folder: docs/_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()
Expand Down
22 changes: 0 additions & 22 deletions docs/_render.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,4 @@ for (fmt in formats) {
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) {
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('blogdown', server = 'bookdown.org', render = 'none')
}
}

setwd(owd)