Build and publish docs #1292
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and publish docs | |
on: | |
schedule: | |
# once per day | |
- cron: "0 0 * * *" | |
# run manually from the GitHub Actions webpage | |
workflow_dispatch: | |
env: | |
CARGO_TERM_COLOR: always | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
path: pages | |
- name: Checkout shadow/shadow | |
uses: actions/checkout@v4 | |
with: | |
path: shadow | |
repository: shadow/shadow | |
persist-credentials: false | |
- name: Upgrade cargo/rust | |
run: rustup update | |
- name: Install dependencies | |
run: sudo apt-get install -y libglib2.0-dev | |
- name: Build rustdoc | |
run: | | |
# don't build docs for shadow's tests | |
(cd shadow/src && cargo doc --workspace --exclude shadow-tests) | |
# rebuild docs for main shadow crate, but with custom version string (shown at top-left of webpage) | |
(cd shadow/src/main && RUSTDOCFLAGS="--crate-version $(git rev-parse --short HEAD)" cargo rustdoc) | |
- name: Copy rustdoc | |
run: | | |
rm -rf pages/docs | |
mkdir pages/docs | |
mv shadow/src/target/doc pages/docs/rust | |
echo '<meta http-equiv="refresh" content="0; url=/docs/rust/shadow_rs/">' > pages/docs/rust/index.html | |
- name: Build guide | |
run: | | |
cargo install --vers "^0.4" mdbook | |
mdbook build --dest-dir ../../pages/docs/guide shadow/mdbook | |
echo '<meta http-equiv="refresh" content="0; url=/docs/guide/">' > pages/docs/index.html | |
- name: Commit | |
run: | | |
COMMIT="$(cd shadow && git rev-parse --short HEAD)" | |
cd pages | |
git config user.name github-actions | |
git config user.email [email protected] | |
git add . | |
git diff-index --quiet HEAD || git commit -m "Generated docs for shadow/shadow@$COMMIT" | |
git push |