|
| 1 | +name: "Deploy to GitHub Pages" |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [master] |
| 6 | + |
| 7 | +env: |
| 8 | + # Use fixed versions for now, replace with 'latest' to auto-use latest |
| 9 | + # Note: during build, there's a warning when using mdbook-toc compiled against an older mdbook version, should work though. |
| 10 | + MDBOOK_VERSION: "0.4.14" |
| 11 | + MDBOOK_TOC_VERSION: "0.7.0" |
| 12 | + MDBOOK_BIN: "/tmp/mdbook-bin" |
| 13 | + |
| 14 | +jobs: |
| 15 | + build_and_deploy: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + |
| 18 | + steps: |
| 19 | + # If using actions/checkout@v2, persist-credentials must be set to false in most cases for the deployment to work correctly. |
| 20 | + - name: "Checkout" |
| 21 | + uses: actions/checkout@v2 |
| 22 | + with: |
| 23 | + persist-credentials: false |
| 24 | + |
| 25 | + # Note: actions-rs/install@v0.1 was considered, but a full 'cargo install' is unnecessarily slow and the cache mechanism is not reliable |
| 26 | + # (error "Unable to download mdbook == 0.4.14 from the tool cache: Error: Unexpected HTTP response: 403") |
| 27 | + # So, directly pull the release from GitHub |
| 28 | + - name: "Install mdbook + mdbook-toc" |
| 29 | + run: | |
| 30 | + wget https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz -O /tmp/mdbook.tar.gz |
| 31 | + wget https://github.com/badboy/mdbook-toc/releases/download/${MDBOOK_TOC_VERSION}/mdbook-toc-${MDBOOK_TOC_VERSION}-x86_64-unknown-linux-gnu.tar.gz -O /tmp/mdbook-toc.tar.gz |
| 32 | + |
| 33 | + mkdir ${MDBOOK_BIN} |
| 34 | + echo ${MDBOOK_BIN} >> $GITHUB_PATH |
| 35 | + tar -xvzf /tmp/mdbook.tar.gz -C ${MDBOOK_BIN} |
| 36 | + tar -xvzf /tmp/mdbook-toc.tar.gz -C ${MDBOOK_BIN} |
| 37 | +
|
| 38 | + - name: "Build book" |
| 39 | + run: mdbook build |
| 40 | + |
| 41 | + - name: "Deploy" |
| 42 | + uses: JamesIves/github-pages-deploy-action@releases/v3 |
| 43 | + with: |
| 44 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 45 | + BRANCH: gh-pages # The branch the action should deploy to. |
| 46 | + FOLDER: book # The folder the action should deploy. |
0 commit comments