Skip to content

Commit

Permalink
Try to build github pages
Browse files Browse the repository at this point in the history
  • Loading branch information
0rphee committed Jan 17, 2025
1 parent 7b51858 commit 9897868
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 5 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/web.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

# Trigger the workflow on push or pull request, but only for the main branch
on:
pull_request:
paths:
- "app/**"
- "asmh.cabal"
- "cabal.project"
- "Setup.hs"
- "src/**"
- "test/**"
- "web/**"
push:
paths:
- "app/**"
- "asmh.cabal"
- "cabal.project"
- "Setup.hs"
- "src/**"
- "test/**"
- "web/**"
workflow_dispatch:

jobs:
build:
name: "Build website"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: nixbuild/nix-quick-install-action@v29
- run: |
nix develop -c "cd web && ./build.sh && ls dist/ && exit 0"
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: './web/dist/'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
30 changes: 27 additions & 3 deletions web/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,33 @@ if [[ $PWD != */web ]]; then
exit 1
fi

outdir=""
case $1 in
dev)
echo "dev run"
outdir="./static/"
;;
prod)
echo "prod run"
npm install
outdir="./dist/"
cp -R static/ $outdir/
;;
*)
echo "This script should be invoked with 'dev' or 'prod' as arguments."
exit 1
;;
esac

wasm32-wasi-cabal build xolsh-exe && wasmpath=$(wasm32-wasi-cabal list-bin xolsh-exe)
cp -f $wasmpath dist/xolsh-exe.wasm

cp -R static/ dist/
cp -f $wasmpath $outdir/xolsh-exe.wasm

esbuild ./src/index.js --bundle --serve=127.0.0.1:9000 --servedir=./dist --outfile=./dist/index.js --global-name=Main --format=esm --platform=browser "--external:node:timers"
case $1 in
dev)
esbuild ./src/index.js --bundle --serve=127.0.0.1:9000 --servedir=./static --outfile=./static/index.js --format=esm --platform=browser "--external:node:timers"
;;
prod)
esbuild ./src/index.js --bundle --outfile=./dist/index.js --format=esm --platform=browser "--external:node:timers"
;;
esac
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"main": "index.js",
"scripts": {
"start": "./build.sh"
"start": "./build.sh dev"
},
"repository": {
"type": "git",
Expand All @@ -24,4 +24,4 @@
"codemirror": "^6.0.1",
"thememirror": "^2.0.1"
}
}
}

0 comments on commit 9897868

Please sign in to comment.