feat(ci): replace ci.yml with ci-deploy.yml #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI & Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| # Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| # --- JOB 1: TEST --- | |
| test: | |
| name: Run Rust Doc Tests | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Install Rust | |
| run: | | |
| rustup set profile minimal | |
| rustup toolchain install stable | |
| rustup default stable | |
| - name: Install latest mdbook | |
| run: | | |
| tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') | |
| url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" | |
| mkdir bin | |
| curl -sSL $url | tar -xz --directory=bin | |
| echo "$(pwd)/bin" >> $GITHUB_PATH | |
| - name: Run tests | |
| run: mdbook test | |
| # --- JOB 2: DEPLOY --- | |
| deploy: | |
| name: Deploy to GitHub Pages | |
| runs-on: ubuntu-latest | |
| needs: test # This ensures Deploy ONLY runs if Test passes! | |
| # This ensures Deploy ONLY runs on the main branch, not on PRs | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| - name: Install latest mdbook | |
| run: | | |
| tag=$(curl 'https://api.github.com/repos/rust-lang/mdbook/releases/latest' | jq -r '.tag_name') | |
| url="https://github.com/rust-lang/mdbook/releases/download/${tag}/mdbook-${tag}-x86_64-unknown-linux-gnu.tar.gz" | |
| mkdir bin | |
| curl -sSL $url | tar -xz --directory=bin | |
| echo "$(pwd)/bin" >> $GITHUB_PATH | |
| - name: Build Book | |
| run: mdbook build | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v4 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: "book" # The default mdbook output folder | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |