Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 85 additions & 85 deletions .github/workflows/web-demos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,99 +13,99 @@ concurrency:
group: web-demos-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
build-and-deploy:
runs-on: ubuntu-latest
env:
CARGO_TARGET_DIR: ${{ github.workspace }}/target
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
# jobs:
# build-and-deploy:
# runs-on: ubuntu-latest
# env:
# CARGO_TARGET_DIR: ${{ github.workspace }}/target
# NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
# NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

steps:
- name: Checkout ⬇️
uses: actions/checkout@v6
# steps:
# - name: Checkout ⬇️
# uses: actions/checkout@v6

- name: Install Nix ❄️
uses: cachix/install-nix-action@v31
# - name: Install Nix ❄️
# uses: cachix/install-nix-action@v31

- name: Set up Cachix ♻️
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
uses: cachix/cachix-action@v17
with:
name: coln
authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}
# - name: Set up Cachix ♻️
# if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository
# uses: cachix/cachix-action@v17
# with:
# name: coln
# authToken: ${{ secrets.CACHIX_AUTH_TOKEN }}

- name: Restore build caches
uses: actions/cache@v4
with:
path: |
.pnpm-store
~/.npm
~/.cargo/registry
~/.cargo/git
~/.ghc-wasm/.cabal
target
dist-newstyle
key: web-demos-${{ runner.os }}-${{ hashFiles('flake.lock', 'Cargo.lock', 'cabal.project', 'packages/**/*.cabal', 'packages/coln-js-runtime/package-lock.json', 'examples/sync-demo/pnpm-lock.yaml') }}
restore-keys: |
web-demos-${{ runner.os }}-
# - name: Restore build caches
# uses: actions/cache@v4
# with:
# path: |
# .pnpm-store
# ~/.npm
# ~/.cargo/registry
# ~/.cargo/git
# ~/.ghc-wasm/.cabal
# target
# dist-newstyle
# key: web-demos-${{ runner.os }}-${{ hashFiles('flake.lock', 'Cargo.lock', 'cabal.project', 'packages/**/*.cabal', 'packages/coln-js-runtime/package-lock.json', 'examples/sync-demo/pnpm-lock.yaml') }}
# restore-keys: |
# web-demos-${{ runner.os }}-

- name: Build sync demo
run: nix run --accept-flake-config .#sync-demo -- "$GITHUB_WORKSPACE"
env:
VITE_BASE: /sync/
# - name: Build sync demo
# run: nix run --accept-flake-config .#sync-demo -- "$GITHUB_WORKSPACE"
# env:
# VITE_BASE: /sync/

- name: Build web compiler
run: |
nix develop --accept-flake-config --command wasm32-wasi-cabal update 'hackage.haskell.org,2026-07-15T17:07:49Z'
nix develop --accept-flake-config --command just examples/build-web-compiler
# - name: Build web compiler
# run: |
# nix develop --accept-flake-config --command wasm32-wasi-cabal update 'hackage.haskell.org,2026-07-15T17:07:49Z'
# nix develop --accept-flake-config --command just examples/build-web-compiler

- name: Assemble deploy directory
run: |
cp examples/index.html examples/style.css _build/web/
cp -r examples/sync-demo/dist _build/web/sync
# - name: Assemble deploy directory
# run: |
# cp examples/index.html examples/style.css _build/web/
# cp -r examples/sync-demo/dist _build/web/sync

- name: Deploy PR preview to Netlify
id: deploy-preview
if: github.event_name == 'pull_request' && env.NETLIFY_AUTH_TOKEN != '' && env.NETLIFY_SITE_ID != ''
run: |
npx --yes netlify-cli@latest deploy \
--auth "$NETLIFY_AUTH_TOKEN" \
--site "$NETLIFY_SITE_ID" \
--dir _build/web \
--no-build \
--alias "pr-${{ github.event.pull_request.number }}" \
--message "PR #${{ github.event.pull_request.number }} web demos" \
--json > netlify-deploy.json
# - name: Deploy PR preview to Netlify
# id: deploy-preview
# if: github.event_name == 'pull_request' && env.NETLIFY_AUTH_TOKEN != '' && env.NETLIFY_SITE_ID != ''
# run: |
# npx --yes netlify-cli@latest deploy \
# --auth "$NETLIFY_AUTH_TOKEN" \
# --site "$NETLIFY_SITE_ID" \
# --dir _build/web \
# --no-build \
# --alias "pr-${{ github.event.pull_request.number }}" \
# --message "PR #${{ github.event.pull_request.number }} web demos" \
# --json > netlify-deploy.json

cat netlify-deploy.json
deploy_url=$(node -e "const d = require('./netlify-deploy.json'); console.log(d.deploy_ssl_url || d.ssl_url || d.deploy_url || d.url)")
echo "deploy-url=$deploy_url" >> "$GITHUB_OUTPUT"
# cat netlify-deploy.json
# deploy_url=$(node -e "const d = require('./netlify-deploy.json'); console.log(d.deploy_ssl_url || d.ssl_url || d.deploy_url || d.url)")
# echo "deploy-url=$deploy_url" >> "$GITHUB_OUTPUT"

- name: Comment with deploy preview URL
if: github.event_name == 'pull_request' && steps.deploy-preview.outputs.deploy-url != ''
uses: actions/github-script@v8
with:
script: |
const marker = '<!-- coln-web-demos-deploy-preview -->'
const body = `${marker}\nWeb demo preview: ${{ steps.deploy-preview.outputs.deploy-url }}`
const { owner, repo } = context.repo
const issue_number = context.issue.number
const comments = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 })
const existing = comments.data.find(comment => comment.body?.includes(marker))
if (existing) {
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body })
} else {
await github.rest.issues.createComment({ owner, repo, issue_number, body })
}
# - name: Comment with deploy preview URL
# if: github.event_name == 'pull_request' && steps.deploy-preview.outputs.deploy-url != ''
# uses: actions/github-script@v8
# with:
# script: |
# const marker = '<!-- coln-web-demos-deploy-preview -->'
# const body = `${marker}\nWeb demo preview: ${{ steps.deploy-preview.outputs.deploy-url }}`
# const { owner, repo } = context.repo
# const issue_number = context.issue.number
# const comments = await github.rest.issues.listComments({ owner, repo, issue_number, per_page: 100 })
# const existing = comments.data.find(comment => comment.body?.includes(marker))
# if (existing) {
# await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body })
# } else {
# await github.rest.issues.createComment({ owner, repo, issue_number, body })
# }

- name: Deploy main to Netlify production
if: github.event_name == 'push' && env.NETLIFY_AUTH_TOKEN != '' && env.NETLIFY_SITE_ID != ''
run: |
npx --yes netlify-cli@latest deploy \
--auth "$NETLIFY_AUTH_TOKEN" \
--site "$NETLIFY_SITE_ID" \
--dir _build/web \
--no-build \
--prod \
--message "web demos ${{ github.sha }}"
# - name: Deploy main to Netlify production
# if: github.event_name == 'push' && env.NETLIFY_AUTH_TOKEN != '' && env.NETLIFY_SITE_ID != ''
# run: |
# npx --yes netlify-cli@latest deploy \
# --auth "$NETLIFY_AUTH_TOKEN" \
# --site "$NETLIFY_SITE_ID" \
# --dir _build/web \
# --no-build \
# --prod \
# --message "web demos ${{ github.sha }}"
Loading