From fb897b32544e6ea69b51c758e64938f718f38af7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Casta=C3=B1o?= Date: Tue, 12 May 2026 22:18:52 -0700 Subject: [PATCH 1/8] Add github actions to deploy from branches. --- .github/workflows/cleanup-branch-deploy.yml | 32 ++++++++++++ .github/workflows/deploy-examples.yml | 58 ++++++++++++--------- 2 files changed, 66 insertions(+), 24 deletions(-) create mode 100644 .github/workflows/cleanup-branch-deploy.yml diff --git a/.github/workflows/cleanup-branch-deploy.yml b/.github/workflows/cleanup-branch-deploy.yml new file mode 100644 index 0000000..6c068ba --- /dev/null +++ b/.github/workflows/cleanup-branch-deploy.yml @@ -0,0 +1,32 @@ +name: Cleanup Branch Deploy + +on: + delete: + +permissions: + contents: write + +jobs: + cleanup: + runs-on: ubuntu-latest + if: github.event.ref_type == 'branch' && github.event.ref != 'main' + steps: + - name: Checkout gh-pages branch + uses: actions/checkout@v4 + with: + ref: gh-pages + + - name: Remove branch directory + run: | + BRANCH_SLUG=$(echo "${{ github.event.ref }}" | sed 's/[^a-zA-Z0-9._-]/-/g') + DEPLOY_DIR="branches/${BRANCH_SLUG}" + if [ -d "$DEPLOY_DIR" ]; then + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git rm -rf "$DEPLOY_DIR" + git commit -m "Clean up deploy for branch: ${{ github.event.ref }}" + git push + echo "Removed ${DEPLOY_DIR}" + else + echo "No deploy directory found for branch: ${{ github.event.ref }}" + fi diff --git a/.github/workflows/deploy-examples.yml b/.github/workflows/deploy-examples.yml index 4896ca2..832c95d 100644 --- a/.github/workflows/deploy-examples.yml +++ b/.github/workflows/deploy-examples.yml @@ -2,23 +2,18 @@ name: Deploy Examples to GitHub Pages on: push: - branches: - - main workflow_dispatch: permissions: - contents: read - pages: write - id-token: write + contents: write concurrency: - group: "pages" - cancel-in-progress: false + group: pages-${{ github.ref_name }} + cancel-in-progress: true jobs: - build: + build-and-deploy: runs-on: ubuntu-latest - environment: github-pages steps: - name: Checkout uses: actions/checkout@v4 @@ -29,6 +24,19 @@ jobs: node-version: "20" cache: "npm" + - name: Determine deploy path + id: config + run: | + if [ "$GITHUB_REF_NAME" = "main" ]; then + echo "base_path=/spark.js/" >> "$GITHUB_OUTPUT" + echo "is_branch=false" >> "$GITHUB_OUTPUT" + else + BRANCH_SLUG=$(echo "$GITHUB_REF_NAME" | sed 's/[^a-zA-Z0-9._-]/-/g') + echo "base_path=/spark.js/branches/${BRANCH_SLUG}/" >> "$GITHUB_OUTPUT" + echo "target_folder=branches/${BRANCH_SLUG}" >> "$GITHUB_OUTPUT" + echo "is_branch=true" >> "$GITHUB_OUTPUT" + fi + - name: Install dependencies run: npm ci @@ -38,23 +46,25 @@ jobs: - name: Build examples run: npm run build:examples env: + BASE_PATH: ${{ steps.config.outputs.base_path }} VITE_ION_KEY: ${{ secrets.VITE_ION_KEY }} - - name: Setup Pages - uses: actions/configure-pages@v5 + - name: Deploy (main) + if: steps.config.outputs.is_branch == 'false' + uses: JamesIves/github-pages-deploy-action@v4 + with: + folder: dist-examples + clean: true + clean-exclude: branches - - name: Upload artifact - uses: actions/upload-pages-artifact@v4 + - name: Deploy (branch) + if: steps.config.outputs.is_branch == 'true' + uses: JamesIves/github-pages-deploy-action@v4 with: - path: "./dist-examples" + folder: dist-examples + target-folder: ${{ steps.config.outputs.target_folder }} - deploy: - environment: - name: github-pages - url: ${{ steps.deployment.outputs.page_url }} - runs-on: ubuntu-latest - needs: build - steps: - - name: Deploy to GitHub Pages - id: deployment - uses: actions/deploy-pages@v4 + - name: Output deployment URL + run: | + echo "## 🚀 Deployment" >> "$GITHUB_STEP_SUMMARY" + echo "**URL:** https://ludicon.github.io${{ steps.config.outputs.base_path }}" >> "$GITHUB_STEP_SUMMARY" From c679b637a75fe4fa895eefdfd4488f3db4b0ba34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Casta=C3=B1o?= Date: Tue, 12 May 2026 22:24:35 -0700 Subject: [PATCH 2/8] Update environment. --- .github/workflows/deploy-examples.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/deploy-examples.yml b/.github/workflows/deploy-examples.yml index 832c95d..a775847 100644 --- a/.github/workflows/deploy-examples.yml +++ b/.github/workflows/deploy-examples.yml @@ -14,6 +14,9 @@ concurrency: jobs: build-and-deploy: runs-on: ubuntu-latest + environment: + name: github-pages + url: https://ludicon.github.io${{ steps.config.outputs.base_path }} steps: - name: Checkout uses: actions/checkout@v4 From 50f7566f260169beca2b5a75e19c0335e212acc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Casta=C3=B1o?= Date: Tue, 12 May 2026 22:28:01 -0700 Subject: [PATCH 3/8] try with preview environment for github pages. --- .github/workflows/deploy-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-examples.yml b/.github/workflows/deploy-examples.yml index a775847..b443785 100644 --- a/.github/workflows/deploy-examples.yml +++ b/.github/workflows/deploy-examples.yml @@ -15,7 +15,7 @@ jobs: build-and-deploy: runs-on: ubuntu-latest environment: - name: github-pages + name: ${{ github.ref_name == 'main' && 'github-pages' || 'preview' }} url: https://ludicon.github.io${{ steps.config.outputs.base_path }} steps: - name: Checkout From bdcf029ac7900be5280431760cc0904566645893 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Casta=C3=B1o?= Date: Tue, 12 May 2026 22:33:48 -0700 Subject: [PATCH 4/8] Upgrade checkout action. --- .github/workflows/deploy-examples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-examples.yml b/.github/workflows/deploy-examples.yml index b443785..81bc59c 100644 --- a/.github/workflows/deploy-examples.yml +++ b/.github/workflows/deploy-examples.yml @@ -19,7 +19,7 @@ jobs: url: https://ludicon.github.io${{ steps.config.outputs.base_path }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v5 - name: Setup Node.js uses: actions/setup-node@v5 From 088b5b2b579302e7ec25afe6875ef3af53ea740d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Casta=C3=B1o?= Date: Tue, 12 May 2026 22:45:57 -0700 Subject: [PATCH 5/8] Try to add missing file. --- .github/workflows/deploy-examples.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/deploy-examples.yml b/.github/workflows/deploy-examples.yml index 81bc59c..0e2aebc 100644 --- a/.github/workflows/deploy-examples.yml +++ b/.github/workflows/deploy-examples.yml @@ -67,6 +67,20 @@ jobs: folder: dist-examples target-folder: ${{ steps.config.outputs.target_folder }} + - name: Ensure .nojekyll exists at gh-pages root + if: steps.config.outputs.is_branch == 'true' + run: | + git fetch origin gh-pages + git checkout gh-pages + if [ ! -f ".nojekyll" ]; then + touch .nojekyll + git config user.name "github-actions[bot]" + git config user.email "github-actions[bot]@users.noreply.github.com" + git add .nojekyll + git commit -m "Add .nojekyll" + git push origin gh-pages + fi + - name: Output deployment URL run: | echo "## 🚀 Deployment" >> "$GITHUB_STEP_SUMMARY" From af014a697ad94b14880ac6799fa4c1710ee0273f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Casta=C3=B1o?= Date: Tue, 12 May 2026 22:50:28 -0700 Subject: [PATCH 6/8] Revert. --- .github/workflows/deploy-examples.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/.github/workflows/deploy-examples.yml b/.github/workflows/deploy-examples.yml index 0e2aebc..81bc59c 100644 --- a/.github/workflows/deploy-examples.yml +++ b/.github/workflows/deploy-examples.yml @@ -67,20 +67,6 @@ jobs: folder: dist-examples target-folder: ${{ steps.config.outputs.target_folder }} - - name: Ensure .nojekyll exists at gh-pages root - if: steps.config.outputs.is_branch == 'true' - run: | - git fetch origin gh-pages - git checkout gh-pages - if [ ! -f ".nojekyll" ]; then - touch .nojekyll - git config user.name "github-actions[bot]" - git config user.email "github-actions[bot]@users.noreply.github.com" - git add .nojekyll - git commit -m "Add .nojekyll" - git push origin gh-pages - fi - - name: Output deployment URL run: | echo "## 🚀 Deployment" >> "$GITHUB_STEP_SUMMARY" From c11d5ad01795e1e9f98bbf0e31746f92c6376117 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ignacio=20Casta=C3=B1o?= Date: Tue, 12 May 2026 23:00:45 -0700 Subject: [PATCH 7/8] Minor edit to test deployment. --- examples/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/index.html b/examples/index.html index 047b8ba..2d5d7e6 100644 --- a/examples/index.html +++ b/examples/index.html @@ -13,7 +13,7 @@ -

WebGPU Examples

+

WebGPU examples

-

WebGL Examples

+

WebGL examples