]>
Commit | Line | Data |
---|---|---|
6a06907d XL |
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: | |
cdc7bbd5 | 14 | if: github.repository == 'rust-lang/rustc-dev-guide' |
6a06907d XL |
15 | runs-on: ubuntu-latest |
16 | env: | |
17 | MDBOOK_VERSION: 0.4.7 | |
18 | MDBOOK_LINKCHECK_VERSION: 0.7.2 | |
19 | MDBOOK_TOC_VERSION: 0.6.1 | |
20 | DEPLOY_DIR: book/html | |
21 | BASE_SHA: ${{ github.event.pull_request.base.sha }} | |
22 | steps: | |
23 | - uses: actions/checkout@v2 | |
24 | with: | |
25 | # linkcheck needs the base commit. | |
26 | fetch-depth: 0 | |
27 | ||
28 | - name: Cache binaries | |
29 | id: mdbook-cache | |
30 | uses: actions/cache@v2 | |
31 | with: | |
32 | path: | | |
33 | ~/.cargo/bin | |
34 | key: ${{ runner.os }}-${{ env.MDBOOK_VERSION }}--${{ env.MDBOOK_LINKCHECK_VERSION }}--${{ env.MDBOOK_TOC_VERSION }} | |
35 | ||
36 | - name: Cache linkcheck | |
37 | uses: actions/cache@v2 | |
38 | with: | |
39 | path: | | |
40 | ~/book/linkcheck | |
41 | key: ${{ runner.os }}-${{ hashFiles('./book/linkcheck') }} | |
42 | ||
43 | - name: Check line lengths | |
44 | if: github.event_name != 'push' | |
45 | run: | | |
46 | shopt -s globstar | |
47 | MAX_LINE_LENGTH=100 bash ci/check_line_lengths.sh src/**/*.md | |
48 | ||
49 | - name: Install latest nightly Rust toolchain | |
50 | if: steps.mdbook-cache.outputs.cache-hit != 'true' | |
51 | uses: actions-rs/toolchain@v1 | |
52 | with: | |
53 | toolchain: nightly | |
54 | override: true | |
55 | ||
56 | - name: Install Dependencies | |
57 | if: steps.mdbook-cache.outputs.cache-hit != 'true' | |
58 | run: | | |
59 | cargo install mdbook --version ${{ env.MDBOOK_VERSION }} | |
60 | cargo install mdbook-linkcheck --version ${{ env.MDBOOK_LINKCHECK_VERSION }} | |
61 | cargo install mdbook-toc --version ${{ env.MDBOOK_TOC_VERSION }} | |
62 | ||
63 | - name: Check build | |
64 | run: mdbook build | |
65 | ||
66 | - name: Deploy to gh-pages | |
cdc7bbd5 | 67 | if: github.event_name == 'push' |
6a06907d XL |
68 | run: | |
69 | touch "${{ env.DEPLOY_DIR }}/.nojekyll" | |
70 | cp CNAME "${{ env.DEPLOY_DIR }}" | |
71 | cd "${{ env.DEPLOY_DIR }}" | |
72 | rm -rf .git | |
73 | git init | |
74 | git config user.name "Deploy from CI" | |
75 | git config user.email "" | |
76 | git add . | |
77 | git commit -m "Deploy ${GITHUB_SHA} to gh-pages" | |
78 | git push --quiet -f "https://x-token:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}" HEAD:gh-pages |