Skip to content

Conversation

@yihui
Copy link
Contributor

@yihui yihui commented Nov 26, 2025

close #1507

@yihui yihui requested a review from cderv November 26, 2025 04:24
@yihui
Copy link
Contributor Author

yihui commented Nov 26, 2025

@cderv Do you mind taking a look at the gh-pages deployment?

- name: Build Gitbook only
env:
DEPLOY_GH_PAGES: ${{ github.event.inputs.ghpages }}
if: github.event_name == 'workflow_dispatch'
run: make -C inst/examples gitbook
- name: Deploy Gitbook to gh-pages
if: github.event_name == 'workflow_dispatch' && github.event.inputs.ghpages
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: inst/examples/_book

I don't remember when it stopped working, but I'm hoping to pull from gh-pages on connect.posit.cloud so we can still enjoy the automatic publishing from CI. Thanks!

@cderv
Copy link
Collaborator

cderv commented Nov 26, 2025

We just added

   if: github.event_name == 'workflow_dispatch'

So it currently only work on manual trigger, and to build book with Pandoc devel

workflow_dispatch:
inputs:
ghpages:
description: 'Build gitbook with pandoc devel and deploy gitbook to gh-page for checking differences'
required: false
default: true

We just need to make it the default way to build book.

I'll make a PR.

@yihui yihui merged commit 994cdec into main Dec 1, 2025
15 checks passed
@yihui yihui deleted the publish-cloud branch December 1, 2025 18:32
@yihui
Copy link
Contributor Author

yihui commented Dec 1, 2025

I can release the new version of bookdown to CRAN at any time. @cderv Is there anything holding the release at the moment?

Copy link

@nealrichardson nealrichardson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few observations, I'm not sure this is quite right but maybe I'm misreading

Comment on lines +35 to +37
# if there are no Connect accounts setup on this machine, offer to add one
# for connect.posit.cloud
if (!'connect.posit.cloud' %in% accounts$server) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless I misunderstand, this will always prompt to create an account (until you have one), even if you've specified account to be something else?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Amended via 425b8fb. Thanks!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification means that if another server is configured (like internal posit server), then connect to connect cloud won't be done by publish_book()

A user will require to use rsconnect::ConnectCloudUser() explicitly in that case to add the server. Then use publish_book(server = "connect.posit.cloud")).

I'll add that in the migration guide.

publish_book = function(name = NULL, account = NULL, server = "connect.posit.cloud", ...) {
# delete local records of bookdown.org
accounts = rsconnect::accounts()
x1 = 'bookdown.org' %in% accounts$server

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would make sense to encapsulate the bookdown server/deployment forgetting into a separate function? A warning message here could alert you to call that function, and then you wouldn't need the interactive readline() prompting, you could just do it because the user called the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The interactive prompting will occur only if bookdown.org was found in the accounts. Since we absolutely want to disable publishing to bookdown.org in the near future, I feel it's more appropriate to do it just here. BTW, for non-interactive R sessions, this will have no effect (readline() returns an empty string, making the condition FALSE).


# configure the account
rsconnect::connectUser(server = 'bookdown.org')
publish_book = function(name = NULL, account = NULL, server = "connect.posit.cloud", ...) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not an expert on how rsconnect works, but IIUC, the old code was relying on the NULL behavior to pick an account/credentials in the case where there is only one server configured in your environment. By making server non-NULL here, we would break the behavior for anyone who is publishing bookdown to a Posit Connect server like that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another good point. Amended via e11cbea.

yihui added a commit that referenced this pull request Dec 2, 2025
…and bookdown.org have been set up (e.g., when another Connect server has been connected before, don't ask to connect to Connect Cloud)

#1512 (comment)
if (x2) rsconnect::removeServer('bookdown.org')
}
if (readline('Do you want to delete local records of the Connect deployment? Your book will _not_ be deleted (y/n) ') == 'y') {
rsconnect::forgetDeployment()
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yihui while making so more testing for the migration guide, I am seeing that this will remove ALL deployments. So we can offer it, but it will prompt to remove all.
Example:

> rsconnect::forgetDeployment("docs")
Forget all deployment records for docs? [Y/n] 
Y

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amended via fa7ca78 (only removing the bookdown.org deployment). Thanks!

Comment on lines +35 to +37
# if there are no Connect accounts setup on this machine, offer to add one
# for connect.posit.cloud
if (!'connect.posit.cloud' %in% accounts$server) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This modification means that if another server is configured (like internal posit server), then connect to connect cloud won't be done by publish_book()

A user will require to use rsconnect::ConnectCloudUser() explicitly in that case to add the server. Then use publish_book(server = "connect.posit.cloud")).

I'll add that in the migration guide.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] Support publishing to connect cloud

4 participants