Skip to content

chore(cdd-web-ui): update built app without wasm binaries #7

chore(cdd-web-ui): update built app without wasm binaries

chore(cdd-web-ui): update built app without wasm binaries #7

name: Deploy Web UI to GitHub Pages
on:
push:
branches: [main, master]
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
env:
DEPLOY_LOCATION: /cdd-web-ui
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout main site (offscale.github.io)
uses: actions/checkout@v4
with:
path: main-site
- name: Checkout cdd-web-ui
uses: actions/checkout@v4
with:
repository: SamuelMarks/cdd-web-ui
path: cdd-web-ui
- name: Checkout cdd-docs-ui
uses: actions/checkout@v4
with:
repository: SamuelMarks/cdd-docs-ui
path: cdd-docs-ui
- name: Checkout cdd-ctl
uses: actions/checkout@v4
with:
repository: SamuelMarks/cdd-ctl
path: cdd-ctl
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install Binaryen
run: sudo apt-get update && sudo apt-get install -y binaryen
- name: Build WASM SDK
working-directory: ./cdd-ctl/cdd-ctl-wasm-sdk
run: |
npm install --ignore-scripts
npm run build
- name: Fetch and Optimize WASM Binaries
working-directory: ./cdd-ctl
run: |
chmod +x ./scripts/fetch_wasm.sh
./scripts/fetch_wasm.sh
mkdir -p ./optimized-wasm
for wasm_file in cdd-ctl-wasm-sdk/assets/wasm/*.wasm; do
filename=$(basename "$wasm_file")
echo "Optimizing $filename..."
wasm-opt -O3 "$wasm_file" -o "./optimized-wasm/$filename" || cp "$wasm_file" "./optimized-wasm/$filename"
done
# Download JS Wrappers and C# Zip manually since fetch_wasm.sh skips them
curl -sL -o ./optimized-wasm/cdd-ts.js "https://github.com/offscale/cdd-ts/releases/latest/download/cdd-ts.js" || true
curl -sL -o ./optimized-wasm/cdd-java.js "https://github.com/SamuelMarks/cdd-java/releases/latest/download/cdd-java.js" || true
curl -sL -o ./cdd-csharp-wasm.zip "https://github.com/SamuelMarks/cdd-csharp/releases/latest/download/cdd-csharp-wasm.zip" || true
# Force python-all, java, and ts to true in the generated JSON since they are now present
sed -i 's/"python-all": false/"python-all": true/g' cdd-ctl-wasm-sdk/assets/wasm-support.json || true
sed -i 's/"java": false/"java": true/g' cdd-ctl-wasm-sdk/assets/wasm-support.json || true
sed -i 's/"ts": false/"ts": true/g' cdd-ctl-wasm-sdk/assets/wasm-support.json || true
- name: Build cdd-docs-ui
working-directory: ./cdd-docs-ui
run: |
npm install --ignore-scripts
npm run build
- name: Install UI Dependencies
working-directory: ./cdd-web-ui
run: npm ci --ignore-scripts
- name: Copy WASM Binaries to Web UI
run: |
mkdir -p cdd-web-ui/public/assets/wasm/cdd-csharp
cp cdd-ctl/optimized-wasm/*.wasm cdd-web-ui/public/assets/wasm/ || true
cp cdd-ctl/optimized-wasm/*.js cdd-web-ui/public/assets/wasm/ || true
unzip -q cdd-ctl/cdd-csharp-wasm.zip -d cdd-web-ui/public/assets/wasm/cdd-csharp/ || true
cp cdd-ctl/cdd-ctl-wasm-sdk/assets/wasm-support.json cdd-web-ui/public/assets/wasm-support.json || true
- name: Compute base-href and Build Angular App
working-directory: ./cdd-web-ui
run: |
echo "Building Angular with --base-href=/cdd-web-ui/"
npx ng build --configuration production --base-href /cdd-web-ui/
- name: Combine Site Artifacts
run: |
rm -rf main-site/cdd-web-ui
cp -r cdd-web-ui/dist/cdd-web-ui/browser main-site/cdd-web-ui
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./main-site
deploy:
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4