summaryrefslogtreecommitdiffstats
path: root/src/doc/embedded-book/.github/workflows/ci.yml
blob: 9018d1146ca99f8871d741013b81c35c72899d4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: CI

on:
  push: # Run CI for all branches except GitHub merge queue tmp branches
    branches-ignore:
    - "gh-readonly-queue/**"
  pull_request: # Run CI for PRs on any branch
  merge_group: # Run CI for the GitHub merge queue

jobs:
  build:
    runs-on: ubuntu-20.04
    steps:
      - uses: actions/checkout@v2
      - uses: actions-rs/toolchain@v1
        with:
          profile: minimal
          toolchain: stable

      - name: Install Python dependencies
        run: |
          pip3 install --user python-dateutil linkchecker
      - name: Put pip binary directory into path
        run: echo "~/.local/bin" >> $GITHUB_PATH

      - name: Cache Cargo installed binaries
        uses: actions/cache@v1
        id: cache-cargo
        with:
          path: ~/cargo-bin
          key: cache-cargo
      - name: Install mdbook
        if: steps.cache-cargo.outputs.cache-hit != 'true'
        uses: actions-rs/install@v0.1
        with:
          crate: mdbook
          version: latest
      - name: Copy mdbook to cache directory
        if: steps.cache-cargo.outputs.cache-hit != 'true'
        run: |
          mkdir ~/cargo-bin
          cp ~/.cargo/bin/mdbook ~/cargo-bin
      - name: Put new cargo binary directory into path
        run: echo "~/cargo-bin" >> $GITHUB_PATH

      - name: Build book
        run: mdbook build
      - name: Test book
        run: mdbook test
      - name: Check links
        run: linkchecker book

      - name: Deploy book
        if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
        uses: peaceiris/actions-gh-pages@v3
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          publish_dir: book
          force_orphan: true