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: 15 additions & 24 deletions .github/workflows/build-book.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ on:
branches:
- master
workflow_dispatch:
inputs:
publish:
description: 'publish the book to github pages for connect cloud deployment'
required: false
default: false
type: boolean

name: build-book

Expand Down Expand Up @@ -42,33 +48,18 @@ jobs:
if: runner.os == 'Linux'
run: sudo apt-get install -y libgtk2.0-dev asymptote

- 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: 7b3dedfa-fd98-45dd-bec4-75d915fb27dd
- name: Build book
run: make all

- uses: actions/github-script@v7
if: github.event_name == 'push'
env:
URL: https://bookdown.org/yihui/rmarkdown-cookbook/
- name: Deploy 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.rest.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: _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
21 changes: 0 additions & 21 deletions _render.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,3 @@ redirect = function(from, to) {

redirect('r-markdown-components.html', 'rmarkdown-process.html')
redirect('acknowledgements.html', 'acknowledgments.html')


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('rmarkdown-cookbook', server = 'bookdown.org', render = 'none')
}
}
Loading