diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b886a4d65..5db03ca4a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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 diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml new file mode 100644 index 000000000..85041c899 --- /dev/null +++ b/.github/workflows/pages.yml @@ -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 cretin@google.com + - run: ./scripts/pages.sh + - run: git push -f origin gh-pages diff --git a/scripts/pages.sh b/scripts/pages.sh index 6481ae509..9d823f177 100755 --- a/scripts/pages.sh +++ b/scripts/pages.sh @@ -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 @@ -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"