| 
 | 1 | +name: CI  | 
 | 2 | + | 
 | 3 | +on:  | 
 | 4 | +  push:  | 
 | 5 | +    branches:  | 
 | 6 | +      - master  | 
 | 7 | +  pull_request:  | 
 | 8 | +  schedule:  | 
 | 9 | +    # Run at 18:00 UTC every day  | 
 | 10 | +    - cron: '0 18 * * *'  | 
 | 11 | + | 
 | 12 | +jobs:  | 
 | 13 | +  ci:  | 
 | 14 | +    if: github.repository == 'rust-lang/rustc-dev-guide'  | 
 | 15 | +    runs-on: ubuntu-latest  | 
 | 16 | +    env:  | 
 | 17 | +      MDBOOK_VERSION: 0.4.21  | 
 | 18 | +      MDBOOK_LINKCHECK2_VERSION: 0.8.1  | 
 | 19 | +      MDBOOK_MERMAID_VERSION: 0.12.6  | 
 | 20 | +      MDBOOK_TOC_VERSION: 0.11.2  | 
 | 21 | +      DEPLOY_DIR: book/html  | 
 | 22 | +      BASE_SHA: ${{ github.event.pull_request.base.sha }}  | 
 | 23 | +      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}  | 
 | 24 | +    steps:  | 
 | 25 | +      - uses: actions/checkout@v4  | 
 | 26 | +        with:  | 
 | 27 | +          # linkcheck needs the base commit.  | 
 | 28 | +          fetch-depth: 0  | 
 | 29 | + | 
 | 30 | +      - name: Cache binaries  | 
 | 31 | +        id: mdbook-cache  | 
 | 32 | +        uses: actions/cache@v4  | 
 | 33 | +        with:  | 
 | 34 | +          path: |  | 
 | 35 | +            ~/.cargo/bin  | 
 | 36 | +          key: ${{ runner.os }}-${{ env.MDBOOK_VERSION }}--${{ env.MDBOOK_LINKCHECK2_VERSION }}--${{ env.MDBOOK_TOC_VERSION }}--${{ env.MDBOOK_MERMAID_VERSION }}  | 
 | 37 | + | 
 | 38 | +      - name: Cache linkcheck  | 
 | 39 | +        uses: actions/cache@v4  | 
 | 40 | +        with:  | 
 | 41 | +          path: |  | 
 | 42 | +            ~/book/linkcheck  | 
 | 43 | +          key: ${{ runner.os }}-${{ hashFiles('./book/linkcheck') }}  | 
 | 44 | + | 
 | 45 | +      - name: Install latest nightly Rust toolchain  | 
 | 46 | +        if: steps.mdbook-cache.outputs.cache-hit != 'true'  | 
 | 47 | +        run: |  | 
 | 48 | +          rustup update nightly  | 
 | 49 | +          rustup override set nightly  | 
 | 50 | +
  | 
 | 51 | +      - name: Install Dependencies  | 
 | 52 | +        if: steps.mdbook-cache.outputs.cache-hit != 'true'  | 
 | 53 | +        run: |  | 
 | 54 | +          cargo install mdbook --version ${{ env.MDBOOK_VERSION }}  | 
 | 55 | +          cargo install mdbook-linkcheck2 --version ${{ env.MDBOOK_LINKCHECK2_VERSION }}  | 
 | 56 | +          cargo install mdbook-toc --version ${{ env.MDBOOK_TOC_VERSION }}  | 
 | 57 | +          cargo install mdbook-mermaid --version ${{ env.MDBOOK_MERMAID_VERSION }}  | 
 | 58 | +
  | 
 | 59 | +      - name: Check build  | 
 | 60 | +        run: ENABLE_LINKCHECK=1 mdbook build  | 
 | 61 | + | 
 | 62 | +      - name: Deploy to gh-pages  | 
 | 63 | +        if: github.event_name == 'push'  | 
 | 64 | +        run: |  | 
 | 65 | +          touch "${{ env.DEPLOY_DIR }}/.nojekyll"  | 
 | 66 | +          cp CNAME "${{ env.DEPLOY_DIR }}"  | 
 | 67 | +          cd "${{ env.DEPLOY_DIR }}"  | 
 | 68 | +          rm -rf .git  | 
 | 69 | +          git init  | 
 | 70 | +          git config user.name "Deploy from CI"  | 
 | 71 | +          git config user.email ""  | 
 | 72 | +          git add .  | 
 | 73 | +          git commit -m "Deploy ${GITHUB_SHA} to gh-pages"  | 
 | 74 | +          git push --quiet -f "https://x-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}" HEAD:gh-pages  | 
0 commit comments