Files
healthchat-web/.github/workflows/build-healthchat-desktop.yaml
T

141 lines
5.4 KiB
YAML

name: Build HealthChat Desktop
# Builds the HealthChat desktop (Electron) app: the fork's element-web webapp with
# the HealthChat plugin (healthchat-module.js + healthchat-elements.js) injected,
# packaged via the existing element-desktop build pipeline.
#
# This mirrors build-healthchat.yaml (web). It first builds the element-plugin from
# healthchat-workspace, builds the fork webapp with the plugin injected, then feeds it
# into build_desktop_prepare.yaml via its `webapp-artifact` input and packages it with
# build_desktop_linux.yaml.
#
# IMPORTANT CAVEATS (see apps/desktop/element.io/healthchat/README):
# - build_desktop_prepare.yaml / build_desktop_linux.yaml currently `actions/checkout`
# `element-hq/element-web` (upstream). The HealthChat webapp + branding come from the
# uploaded artifact + variant.json, but the Electron shell (electron-main, icons) is
# upstream Element's. To ship a fully fork-branded shell, point those reusable
# workflows at this fork (change their `repository:` / add a `ref` input).
# - Plugin loading depends on element-main.ts rewriting `/modules/*` -> `/webapp/modules/*`.
# Verify that rewrite exists in whichever desktop checkout is used.
# - macOS/Windows builds need Element's signing/notarization secrets and are intentionally
# omitted here; add build_desktop_macos.yaml / build_desktop_windows.yaml once those are
# available.
# - Confirm `ch.healthchat.api_base_url` in apps/desktop/element.io/healthchat/config.json
# points at the real production API origin (assumed https://healthchat.ch).
on:
workflow_dispatch:
inputs:
version:
description: "Version (e.g. 1.4.0)."
required: true
type: string
workspace_ref:
description: "healthchat-workspace ref (defaults to .healthchat-workspace-version)."
required: false
type: string
permissions: {}
concurrency:
group: build-healthchat-desktop-${{ github.event.inputs.version }}
cancel-in-progress: false
jobs:
webapp:
name: Build webapp + plugin
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
with:
persist-credentials: false
- name: Resolve workspace ref
id: workspace
env:
OVERRIDE: ${{ github.event.inputs.workspace_ref }}
run: |
set -euo pipefail
if [[ -n "$OVERRIDE" ]]; then
REF="$OVERRIDE"
elif [[ -f .healthchat-workspace-version ]]; then
REF=$(head -n1 .healthchat-workspace-version | tr -d '[:space:]')
[[ -n "$REF" ]] || { echo "::error::.healthchat-workspace-version is empty"; exit 1; }
else
echo "::error::.healthchat-workspace-version missing and no workspace_ref override provided"
exit 1
fi
echo "ref=$REF" >> "$GITHUB_OUTPUT"
- name: Checkout healthchat-workspace
uses: actions/checkout@v4
with:
repository: Novaloop-AG/healthchat-workspace
path: healthchat-workspace
token: ${{ secrets.HEALTHCHAT_WORKSPACE_TOKEN }}
ref: ${{ steps.workspace.outputs.ref }}
persist-credentials: false
- uses: pnpm/action-setup@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: "pnpm"
- name: Install monorepo deps
run: pnpm install --frozen-lockfile
- name: Build element-plugin
run: |
cd healthchat-workspace/element-plugin
npm ci
npm run build
cd module
npm ci
npm run build
- name: Stage plugin artifacts
run: |
mkdir -p plugin-dist/elements
cp healthchat-workspace/element-plugin/module/dist/healthchat-module.js plugin-dist/healthchat-module.js
cp healthchat-workspace/element-plugin/dist/elements/browser/main.js plugin-dist/elements/healthchat-elements.js
- name: Build webapp with plugin injected
env:
VERSION: ${{ github.event.inputs.version }}
run: ./apps/desktop/scripts/build-healthchat-webapp.sh
- uses: actions/upload-artifact@v4
with:
name: healthchat-webapp
retention-days: 1
path: apps/desktop/webapp
prepare:
name: Prepare desktop asar
needs: webapp
permissions:
contents: read
uses: ./.github/workflows/build_desktop_prepare.yaml
with:
config: element.io/healthchat
webapp-artifact: healthchat-webapp
nightly: false
deploy: false
linux:
name: Linux ${{ matrix.arch }}
needs: prepare
strategy:
matrix:
arch: [amd64, arm64]
uses: ./.github/workflows/build_desktop_linux.yaml
with:
arch: ${{ matrix.arch }}
sqlcipher: static
version: ${{ github.event.inputs.version }}
test: false