Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically deploy the book #245

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,5 @@ jobs:
target/
key: ${{ hashFiles('rust-toolchain.toml') }}-${{ hashFiles('**/Cargo.lock') }}
restore-keys: ${{ hashFiles('rust-toolchain.toml') }}
- run: sudo apt-get update
- run: ./scripts/setup.sh
- run: ./scripts/ci.sh
21 changes: 21 additions & 0 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Deploy Github Pages

on:
push:
branches:
- main

jobs:
pages:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- run: ./scripts/setup.sh
- run: git config --global user.name 'Julien Cretin'
- run: git config --global user.email [email protected]
- run: ./scripts/pages.sh
- run: git push -f origin gh-pages
9 changes: 6 additions & 3 deletions scripts/pages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,14 @@ set -e
# This script synchronizes the gh-pages branch from a clean main.

[ -z "$(git status -s)" ] || e 'not clean'
[ "$(git symbolic-ref -q HEAD)" = refs/heads/main ] || e 'not main'
[ -n "$CI" -o "$(git symbolic-ref -q HEAD)" = refs/heads/main ] || e 'not main'
COMMIT="$(git rev-parse -q --verify HEAD)"
[ -n "$COMMIT" ] || e 'failed to get commit hash'

git diff --quiet "$(git log --pretty=format:%f origin/gh-pages)".. -- book \
&& d "origin/gh-pages is already up-to-date"

WASEFIRE_WRAPPER_EXEC=n ./scripts/wrapper.sh mdbook
( cd book
../scripts/wrapper.sh mdbook build 2>/dev/null )
mv book/book html
Expand All @@ -32,9 +35,9 @@ git show-ref -q --verify refs/heads/gh-pages && git branch -qD gh-pages
git checkout -q --orphan gh-pages
git rm -qrf .
git clean -qfxde/html
mv html/* html/.* .
find html -mindepth 1 -maxdepth 1 -exec mv {} . \;
rmdir html
git add .
git commit -qm"$(git rev-parse -q --verify main)"
git commit -qm"$COMMIT"
git checkout -q main
d "gh-pages has been updated"