forked from rust-osdev/uefi-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (47 loc) · 1.83 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
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 a worktree for the tag.
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
# Build the book for the tag. Don't use `--dest-dir` because it will
# delete the destination directory including the worktree checkout's
# ".git".
mdbook build wt-tag/book
# Copy output to the destination directory. Note the "/." is needed at
# the end of the source path so that hidden files are included.
cp -r wt-tag/book/book/. wt-gh-pages
# Commit and push.
cd wt-gh-pages
git add .
git commit -m "Deploy $GITHUB_SHA to gh-pages"
git push --force