|
| 1 | +# Sample workflow for building and deploying a mdBook site to GitHub Pages |
| 2 | +# |
| 3 | +# To get started with mdBook see: https://rust-lang.github.io/mdBook/index.html |
| 4 | +# |
| 5 | +name: Deploy mdBook site to Pages |
| 6 | + |
| 7 | +on: |
| 8 | + # Runs on pushes targeting the default branch |
| 9 | + push: |
| 10 | + branches: ["main"] |
| 11 | + |
| 12 | + # Allows you to run this workflow manually from the Actions tab |
| 13 | + workflow_dispatch: |
| 14 | + |
| 15 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 16 | +permissions: |
| 17 | + contents: read |
| 18 | + pages: write |
| 19 | + id-token: write |
| 20 | + |
| 21 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 22 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 23 | +concurrency: |
| 24 | + group: "pages" |
| 25 | + cancel-in-progress: false |
| 26 | + |
| 27 | +env: |
| 28 | + MDBOOK_VERSION: 0.4.21 |
| 29 | + MDBOOK_ALERTS_VERSION: 0.6.7 |
| 30 | + MDBOOK_LINKCHECK_VERSION: 0.7.7 |
| 31 | + PUBLISH_DOMAIN: component-model.bytecodealliance.org |
| 32 | + |
| 33 | +jobs: |
| 34 | + # Build job |
| 35 | + build: |
| 36 | + runs-on: ubuntu-latest |
| 37 | + steps: |
| 38 | + - uses: actions/checkout@v3 |
| 39 | + |
| 40 | + - uses: taiki-e/cache-cargo-install-action@v2 |
| 41 | + with: |
| 42 | + tool: mdbook@${{ env.MDBOOK_VERSION }} |
| 43 | + |
| 44 | + - uses: taiki-e/cache-cargo-install-action@v2 |
| 45 | + with: |
| 46 | + tool: mdbook-alerts@${{ env.MDBOOK_ALERTS_VERSION }} |
| 47 | + |
| 48 | + - uses: taiki-e/cache-cargo-install-action@v2 |
| 49 | + with: |
| 50 | + tool: mdbook-linkcheck@${{ env.MDBOOK_LINKCHECK_VERSION }} |
| 51 | + |
| 52 | + - name: Setup Pages |
| 53 | + id: pages |
| 54 | + uses: actions/configure-pages@v3 |
| 55 | + |
| 56 | + - name: Build with mdBook |
| 57 | + run: mdbook build component-model |
| 58 | + |
| 59 | + - name: Setup Python |
| 60 | + uses: actions/setup-python@v5 |
| 61 | + with: |
| 62 | + python-version: '3.13' |
| 63 | + |
| 64 | + - name: Generate sitemap |
| 65 | + run: | |
| 66 | + cd component-model |
| 67 | + python3 ../scripts/generate_sitemap.py --domain "component-model.bytecodealliance.org" --higher-priority "design" --output-path book/sitemap.xml |
| 68 | + cd .. |
| 69 | + - name: Upload artifact |
| 70 | + uses: actions/upload-pages-artifact@v3 |
| 71 | + with: |
| 72 | + path: ./component-model/book |
| 73 | + |
| 74 | + # Deployment job |
| 75 | + deploy: |
| 76 | + if: ${{ github.repository_owner == 'bytecodealliance' }} |
| 77 | + environment: |
| 78 | + name: github-pages |
| 79 | + url: ${{ steps.deployment.outputs.page_url }} |
| 80 | + runs-on: ubuntu-latest |
| 81 | + needs: build |
| 82 | + steps: |
| 83 | + - name: Deploy to GitHub Pages |
| 84 | + id: deployment |
| 85 | + uses: actions/deploy-pages@v4 |
0 commit comments