|
1 | | -name: Rust Test and Deplou to GitHub Pages |
| 1 | +name: Deploy Rust Docs |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | 5 | branches: [ "main" ] |
6 | | - pull_request: |
7 | | - branches: [ "main" ] |
| 6 | + # Allows you to run this workflow manually from the Actions tab |
| 7 | + workflow_dispatch: |
8 | 8 |
|
9 | 9 | permissions: |
10 | 10 | contents: read |
11 | 11 | pages: write |
12 | 12 | id-token: write |
13 | | -env: |
14 | | - CARGO_TERM_COLOR: always |
15 | 13 |
|
16 | 14 | jobs: |
17 | | - build: |
18 | | - |
| 15 | + build-and-deploy: |
19 | 16 | runs-on: ubuntu-latest |
20 | | - |
21 | 17 | steps: |
22 | | - - uses: actions/checkout@v4 |
23 | | - - name: Build |
24 | | - run: cargo build --verbose |
25 | | - - name: Run tests |
26 | | - run: cargo test --verbose |
27 | | - - name: Generate Documentation |
28 | | - run: cargo doc --no-deps --document-private-items |
29 | | - - name: Setup Pages |
30 | | - uses: actions/configure-pages@v4 |
31 | | - - name: Upload Artifact |
32 | | - uses: actions/upload-pages-artifact@v3 |
33 | | - with: |
34 | | - # Path to the generated docs |
35 | | - path: target/doc |
36 | | - - name: Deploy to GitHub Pages |
37 | | - uses: actions/deploy-pages@v4 |
| 18 | + - name: Checkout Repository |
| 19 | + uses: actions/checkout@v4 |
| 20 | + |
| 21 | + - name: Install Rust |
| 22 | + uses: dtolnay/rust-toolchain@stable |
| 23 | + |
| 24 | + - name: Generate Documentation |
| 25 | + run: cargo doc --no-deps --document-private-items |
| 26 | + |
| 27 | + - name: Create Root Redirect |
| 28 | + # This prevents the 404 by pointing the root to your crate's folder |
| 29 | + run: | |
| 30 | + echo '<meta http-equiv="refresh" content="0; url=web_server_made_rusty/index.html">' > target/doc/index.html |
| 31 | +
|
| 32 | + - name: Fix Permissions |
| 33 | + run: chmod -v -R +rX "target/doc/" |
| 34 | + |
| 35 | + - name: Upload Artifact |
| 36 | + uses: actions/upload-pages-artifact@v3 |
| 37 | + with: |
| 38 | + path: target/doc |
| 39 | + |
| 40 | + - name: Deploy to GitHub Pages |
| 41 | + uses: actions/deploy-pages@v4 |
0 commit comments