forked from rust-osdev/uefi-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (49 loc) · 2.05 KB
/
book.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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 wt-main refs/remotes/origin/main
git worktree add wt-tag refs/tags/"${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. The dest dir is
# relative to the second path.
mdbook build --dest-dir ../../wt-gh-pages/HEAD wt-main/book
mdbook build --dest-dir ../../wt-gh-pages/latest-release wt-tag/book
# Add an index in the root to redirect to the latest release.
cp wt-main/book/redirect.html wt-gh-pages/index.html
# Commit and push.
cd wt-gh-pages
git add HEAD latest-release index.html
git commit -m "Deploy $GITHUB_SHA to gh-pages"
git push --force