CI #3708
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: CI | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
schedule: | |
# Run at 18:00 UTC every day | |
- cron: '0 18 * * *' | |
jobs: | |
ci: | |
if: github.repository == 'rust-lang/rustc-dev-guide' | |
runs-on: ubuntu-latest | |
env: | |
MDBOOK_VERSION: 0.4.21 | |
MDBOOK_LINKCHECK_VERSION: 0.7.6 | |
MDBOOK_MERMAID_VERSION: 0.12.6 | |
MDBOOK_TOC_VERSION: 0.11.2 | |
DEPLOY_DIR: book/html | |
BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
# linkcheck needs the base commit. | |
fetch-depth: 0 | |
- name: Cache binaries | |
id: mdbook-cache | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.cargo/bin | |
key: ${{ runner.os }}-${{ env.MDBOOK_VERSION }}--${{ env.MDBOOK_LINKCHECK_VERSION }}--${{ env.MDBOOK_TOC_VERSION }}--${{ env.MDBOOK_MERMAID_VERSION }} | |
- name: Cache linkcheck | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/book/linkcheck | |
key: ${{ runner.os }}-${{ hashFiles('./book/linkcheck') }} | |
- name: Install latest nightly Rust toolchain | |
if: steps.mdbook-cache.outputs.cache-hit != 'true' | |
run: | | |
rustup update nightly | |
rustup override set nightly | |
- name: Install Dependencies | |
if: steps.mdbook-cache.outputs.cache-hit != 'true' | |
run: | | |
cargo install mdbook --version ${{ env.MDBOOK_VERSION }} | |
cargo install mdbook-linkcheck --version ${{ env.MDBOOK_LINKCHECK_VERSION }} | |
cargo install mdbook-toc --version ${{ env.MDBOOK_TOC_VERSION }} | |
cargo install mdbook-mermaid --version ${{ env.MDBOOK_MERMAID_VERSION }} | |
- name: Check build | |
run: mdbook build | |
- name: Deploy to gh-pages | |
if: github.event_name == 'push' | |
run: | | |
touch "${{ env.DEPLOY_DIR }}/.nojekyll" | |
cp CNAME "${{ env.DEPLOY_DIR }}" | |
cd "${{ env.DEPLOY_DIR }}" | |
rm -rf .git | |
git init | |
git config user.name "Deploy from CI" | |
git config user.email "" | |
git add . | |
git commit -m "Deploy ${GITHUB_SHA} to gh-pages" | |
git push --quiet -f "https://x-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}" HEAD:gh-pages |