Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow deploy_to_branch() to deploy to a configurable subdirectory of the branch #2001

Merged
merged 4 commits into from
Jan 7, 2022

Conversation

gadenbuie
Copy link
Contributor

This is a small PR to add a subdir argument to deploy_to_branch(). By default (as currently) deploy_to_branch() deploys the packge documentation into the root of a branch, typically an orphan gh-pages branch.

When subdir is provided, deploy_to_branch() will set up the git worktree the same as before, but will build the site into the requested subdir of the branch. This enables a variety of site structures, but the two I'm most excited about are:

  1. Enabling PR previews via GitHub Actions by building the site preview into preview/pr${{ github.event.pull_request.number }}.

  2. Enabling documentation for multiple package versions, for example based on tags, by building the site into separate folders, e.g. subdir = "v2" and subdir = "v3".

As part of the process, we also append the subdir to pkg$meta$url, e.g. https://pkg.example.com/v2. To facilitate that change, I moved the as_pkgdown() call into deploy_to_branch(), which required also overriding the destination here rather than in build_site_github_pages().

@hadley
Copy link
Member

hadley commented Jan 7, 2022

Do you want to add a news bullet? I'm not convinced this is the direction we want to go in the long term (since I think it might be better for us to use same GitHub pages deployment for bookdown, blogdown, ...) but I don't think it's harmful to include it and it certainly seems like it will enable some interesting experiments.

@gadenbuie
Copy link
Contributor Author

Just added a news bullet! I'm looking forward to a consolidated GitHub Pages deployment, but I'll also be glad to have this feature. By the way, the use of git worktree is quite clever and I learned a lot from looking into this.

@hadley hadley merged commit 4749378 into r-lib:main Jan 7, 2022
@hadley
Copy link
Member

hadley commented Jan 7, 2022

Thanks!

@gadenbuie gadenbuie deleted the deploy-to-branch-subdir branch January 7, 2022 20:35
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.

None yet

2 participants