mirror of https://github.com/rust-lang/mdBook.git
0
Automated Deployment: GitHub Pages (Deploy from branch)
Eric Huss edited this page 2024-04-29 13:52:03 -07:00
The following contains general instructions on how to manually deploy to GitHub Pages from a branch.
See Automated Deployment: GitHub Actions#GitHub Pages Deploy for instructions if you are using GitHub Actions.
This is the general outline of a shell script that will build the book, add its contents to the gh-pages
branch, and push that branch. This may need editing based on your needs (such as if the book is located in a subdirectory, etc.).
# Installs mdbook
mkdir mdbook
# Consider using a service like renovatebot if you want to automatically update the version here.
curl -Lf https://github.com/rust-lang/mdBook/releases/download/v0.4.37/mdbook-v0.4.37-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
# Build the book
mdbook build
# If the gh-pages branch already exists, this will overwrite it
# so that the history is not kept, which can be very expensive.
git worktree add --orphan -B gh-pages gh-pages
cp -r book/ gh-pages
git config user.name "Deploy from CI"
git config user.email ""
cd gh-pages
git add -A
git commit -m 'deploy new book'
git push origin +gh-pages
cd ..