refactor: Replace fragile text comparison with step index check #1072
This file contains 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: Freenet Deploy | |
on: | |
push: | |
branches: | |
- main # Deploy when pushing to main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
steps: | |
# Checkout the repository | |
- uses: actions/checkout@v4 | |
with: | |
submodules: true # Fetch Hugo themes (true OR recursive) | |
fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod | |
# Setup Hugo for static site generation | |
- name: Setup Hugo | |
uses: peaceiris/actions-hugo@v3 | |
with: | |
hugo-version: '0.133.1' | |
extended: true | |
# Setup Rust environment | |
- name: Setup Rust | |
uses: dtolnay/rust-toolchain@stable | |
with: | |
components: rustfmt, clippy | |
# Add WebAssembly target for Rust | |
- name: Add WebAssembly target | |
run: rustup target add wasm32-unknown-unknown | |
# Install WebAssembly tools | |
- name: Install wasm-pack and wasm-bindgen-cli | |
run: | | |
curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
cargo install --force wasm-pack | |
cargo install --force wasm-bindgen-cli | |
# Install cargo-make for building | |
- name: Install cargo-make | |
run: cargo install --debug cargo-make | |
# Cache WebAssembly files | |
- name: Cache WebAssembly files | |
id: cache-wasm | |
uses: actions/cache@v3 | |
with: | |
path: hugo-site/static/wasm | |
key: ${{ runner.os }}-wasm-${{ hashFiles('rust/gkwasm/**', 'rust/gklib/**') }} | |
# Build WebAssembly if cache miss or files changed | |
- name: Build WebAssembly | |
if: steps.cache-wasm.outputs.cache-hit != 'true' | |
run: cargo make build-wasm-release | |
# Build the site using cargo-make | |
- name: Build Site | |
run: cargo make build-site | |
# Verify the contents of the build | |
- name: Verify WebAssembly files in build | |
run: | | |
echo "Contents of hugo-site/public/wasm:" | |
ls -la hugo-site/public/wasm | |
# Upload the built site to GitHub Pages artifact | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v1 | |
with: | |
path: hugo-site/public # Point to the correct directory | |
deploy: | |
needs: build | |
runs-on: ubuntu-22.04 | |
permissions: | |
pages: write | |
id-token: write | |
steps: | |
# Deploy to GitHub Pages | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v1 | |
with: | |
cname: freenet.org |