Skip to content

Merge pull request #47 from nicholasbishop/bishop-book-split-2 #72

Merge pull request #47 from nicholasbishop/bishop-book-split-2

Merge pull request #47 from nicholasbishop/bishop-book-split-2 #72

Workflow file for this run

name: Book
on:
push:
branches: [main]
tags: ['*']
permissions:
contents: write
# Adapted from:
# https://github.com/rust-lang/mdBook/wiki/Automated-Deployment%3A-GitHub-Actions#github-pages-deploy
jobs:
deploy:
# if: github.repository == 'rust-osdev/uefi-rs'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install mdbook
run: |
mkdir mdbook
curl -sSL https://github.com/rust-lang/mdBook/releases/download/v0.4.21/mdbook-v0.4.21-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=./mdbook
echo `pwd`/mdbook >> $GITHUB_PATH
- name: Deploy GitHub Pages
run: |
# Configure git user so that `git commit` works.
git config user.name "Deploy from CI"
git config user.email ""
# Get the highest `uefi` release tag.
highest_tag="$(git tag --list | grep uefi-v | sort -V | tail -1)"
# Create worktrees for both the `main` branch and the highest tag.
git worktree add --detach wt-main main
git worktree add --detach wt-tag "${highest_tag}"
# Create a worktree for the `gh-pages` branch.
git worktree add wt-gh-pages gh-pages
# Delete the ref to avoid keeping history.
git -C wt-gh-pages update-ref -d refs/heads/gh-pages
# Delete existing book builds.
rm -rf wt-gh-pages/HEAD wt-gh-pages/latest-release
# Build the book for both `main` and the highest tag.
mdbook build --dest-dir wt-gh-pages/HEAD wt-main
mdbook build --dest-dir wt-gh-pages/latest-release wt-tag
cd wt-gh-pages
# Add an index in the root to redirect to the latest release.
cp ../redirect.html index.html
# Commit and push.
git add HEAD latest-release index.html
git commit -m "Deploy $GITHUB_SHA to gh-pages"
git push --force