|
| 1 | +# See https://book.leptos.dev/deployment/csr.html#github-pages |
| 2 | +name: Release to Github Pages |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + branches: [main, deploy-github-pages] |
| 7 | + paths: |
| 8 | + - 'platforms/web/**' |
| 9 | + - '.github/workflows/github-pages.yml' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +permissions: |
| 13 | + contents: write # for committing to gh-pages branch. |
| 14 | + pages: write |
| 15 | + id-token: write |
| 16 | + |
| 17 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 18 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 19 | +concurrency: |
| 20 | + group: "pages" |
| 21 | + cancel-in-progress: false |
| 22 | + |
| 23 | +env: |
| 24 | + WASM_PATH: ./platforms/web |
| 25 | + |
| 26 | +jobs: |
| 27 | + Github-Pages-Release: |
| 28 | + defaults: |
| 29 | + run: |
| 30 | + working-directory: ${{ env.WASM_PATH }} |
| 31 | + |
| 32 | + timeout-minutes: 10 |
| 33 | + |
| 34 | + environment: |
| 35 | + name: github-pages |
| 36 | + url: ${{ steps.deployment.outputs.page_url }} |
| 37 | + |
| 38 | + runs-on: ubuntu-latest |
| 39 | + |
| 40 | + steps: |
| 41 | + - uses: actions/checkout@v4 # repo checkout |
| 42 | + |
| 43 | + # Install Rust Nightly Toolchain, with Clippy & Rustfmt |
| 44 | + - name: Install nightly Rust |
| 45 | + uses: dtolnay/rust-toolchain@nightly |
| 46 | + |
| 47 | + - name: Add WASM target |
| 48 | + run: rustup target add wasm32-unknown-unknown |
| 49 | + |
| 50 | + - name: Download and install Trunk binary |
| 51 | + run: wget -qO- https://github.com/trunk-rs/trunk/releases/download/v0.21.14/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf- |
| 52 | + |
| 53 | + - name: Build with Trunk |
| 54 | + # The behavior of the --public-url argument has changed: it no longer includes a leading '/'. |
| 55 | + # We have to specify it explicitly. See https://github.com/trunk-rs/trunk/issues/668 |
| 56 | + run: ./trunk build --release --public-url "/${GITHUB_REPOSITORY#*/}" |
| 57 | + |
| 58 | + # Deploy with Github Static Pages |
| 59 | + - name: Setup Pages |
| 60 | + uses: actions/configure-pages@v5 |
| 61 | + with: |
| 62 | + enablement: true |
| 63 | + # token: |
| 64 | + |
| 65 | + - name: Upload artifact |
| 66 | + uses: actions/upload-pages-artifact@v3 |
| 67 | + with: |
| 68 | + # Upload dist dir |
| 69 | + path: "${{ env.WASM_PATH }}/dist" |
| 70 | + |
| 71 | + - name: Deploy to GitHub Pages 🚀 |
| 72 | + id: deployment |
| 73 | + uses: actions/deploy-pages@v4 |
0 commit comments