diff --git a/.github/workflows/build-book.yaml b/.github/workflows/build-book.yaml index 3740a749..ef3c50da 100644 --- a/.github/workflows/build-book.yaml +++ b/.github/workflows/build-book.yaml @@ -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 @@ -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() diff --git a/_render.R b/_render.R index 4c0028ec..358e27fd 100644 --- a/_render.R +++ b/_render.R @@ -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') - } -}