|
| 1 | +name: CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ staging, trying, master ] |
| 6 | + pull_request: |
| 7 | + |
| 8 | +jobs: |
| 9 | + # Check a build succeeds for each chapter that contains example code. |
| 10 | + build-chapter: |
| 11 | + runs-on: ubuntu-20.04 |
| 12 | + strategy: |
| 13 | + matrix: |
| 14 | + chapter: |
| 15 | + - 05-led-roulette |
| 16 | + - 06-hello-world |
| 17 | + - 07-registers |
| 18 | + - 08-leds-again |
| 19 | + - 09-clocks-and-timers |
| 20 | + - 11-usart |
| 21 | + - 14-i2c |
| 22 | + - 15-led-compass |
| 23 | + - 16-punch-o-meter |
| 24 | + steps: |
| 25 | + - uses: actions/checkout@v2 |
| 26 | + - uses: actions-rs/toolchain@v1 |
| 27 | + with: |
| 28 | + profile: minimal |
| 29 | + toolchain: stable |
| 30 | + target: thumbv7em-none-eabihf |
| 31 | + - name: Build chapter |
| 32 | + working-directory: src/${{ matrix.chapter }} |
| 33 | + run: cargo build |
| 34 | + |
| 35 | + # Build the book HTML itself and optionally publish it. |
| 36 | + build-book: |
| 37 | + runs-on: ubuntu-20.04 |
| 38 | + steps: |
| 39 | + - uses: actions/checkout@v2 |
| 40 | + - uses: actions-rs/toolchain@v1 |
| 41 | + with: |
| 42 | + profile: minimal |
| 43 | + toolchain: stable |
| 44 | + target: thumbv7em-none-eabihf |
| 45 | + |
| 46 | + - name: Install Python dependencies |
| 47 | + run: | |
| 48 | + pip3 install --user python-dateutil linkchecker |
| 49 | + - name: Put pip binary directory into path |
| 50 | + run: echo "~/.local/bin" >> $GITHUB_PATH |
| 51 | + |
| 52 | + - name: Cache Cargo installed binaries |
| 53 | + uses: actions/cache@v1 |
| 54 | + id: cache-cargo |
| 55 | + with: |
| 56 | + path: ~/cargo-bin |
| 57 | + key: cache-cargo |
| 58 | + - name: Install mdbook |
| 59 | + if: steps.cache-cargo.outputs.cache-hit != 'true' |
| 60 | + uses: actions-rs/[email protected] |
| 61 | + with: |
| 62 | + crate: mdbook |
| 63 | + version: latest |
| 64 | + - name: Copy mdbook to cache directory |
| 65 | + if: steps.cache-cargo.outputs.cache-hit != 'true' |
| 66 | + run: | |
| 67 | + mkdir ~/cargo-bin |
| 68 | + cp ~/.cargo/bin/mdbook ~/cargo-bin |
| 69 | + - name: Put new cargo binary directory into path |
| 70 | + run: echo "~/cargo-bin" >> $GITHUB_PATH |
| 71 | + |
| 72 | + - name: Build book |
| 73 | + run: mdbook build |
| 74 | + - name: Check links |
| 75 | + run: linkchecker --ignore-url "print.html" book |
| 76 | + |
| 77 | + - name: Deploy book |
| 78 | + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} |
| 79 | + uses: peaceiris/actions-gh-pages@v3 |
| 80 | + with: |
| 81 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + publish_dir: book |
| 83 | + force_orphan: true |
0 commit comments