# Build and deploy
deploy_site()
# Deploy without rebuilding (if docs are already up to date)
deploy_site(build = FALSE)Deploy site to Pages branch
Source: R/usethis.R
Builds the documentation site and pushes the contents of docs/ to a pages branch. This is a manual deployment method that works with both GitHub Pages and Codeberg Pages.
Usage
deploy_site(
pkg = ".",
branch = "pages",
remote = "origin",
build = TRUE,
commit_message = "Update documentation site"
)Arguments
-
pkg -
Path to the package root directory
-
branch -
The branch to deploy to. Defaults to “pages”.
-
remote -
The git remote to push to. Defaults to “origin”.
-
build -
Whether to rebuild the site before deploying. Defaults to TRUE.
-
commit_message -
Commit message for committing
docs/to the current branch, and for the deploy commit. If NULL,docs/is not committed to the current branch and the deploy commit uses a default message.
Value
Invisibly returns the SHA of the deployed commit
Details
The pages branch only ever holds the current site. Each deploy creates a single commit containing the files in docs/ as they are on disk and force-pushes it to branch, replacing whatever was there. Pushing one commit rather than the whole history of docs/ keeps the push small, which avoids the timeouts that a first deploy to Codeberg can hit.
The snapshot is taken through a temporary git index, so nothing you have staged on the current branch is touched. After pushing, the remote branch is read back and the deploy only reports success if it points at the new commit. Any git failure stops the deploy with git’s own error message.