fix(ci): npx --package=@fhir-dsl/cli — bin name (fhir-gen) doesn't ma… #114
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Docs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'apps/docs/**' | |
| - 'apps/his-demo/**' | |
| - 'packages/**' | |
| - '.github/workflows/deploy-docs.yml' | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build workspace packages | |
| # Builds every @fhir-dsl/* package (excludes apps/his-demo via the | |
| # root build script's filter). Required so the @fhir-dsl/cli dist | |
| # exists for the demo gen step below. | |
| run: pnpm build | |
| - name: Build Docusaurus | |
| working-directory: apps/docs | |
| run: pnpm build | |
| - name: Generate FHIR types for demo | |
| # npx needs --package because @fhir-dsl/cli's bin is named `fhir-gen`, | |
| # not `cli` — npx can't auto-resolve. Explicit form fetches the package | |
| # from npm and runs the right binary. | |
| working-directory: apps/his-demo | |
| run: npx -y --package=@fhir-dsl/cli fhir-gen generate --version r4 --validator native --expand-valuesets --resolve-codesystems --cache ./.fhir-cache --out ./src/fhir/r4 | |
| - name: Build demo (static SPA) | |
| working-directory: apps/his-demo | |
| env: | |
| DEMO_STATIC: '1' | |
| DEMO_BASE_PATH: /fhir-dsl/demo/ | |
| run: pnpm build | |
| - name: Stage demo into docs build | |
| run: | | |
| set -euo pipefail | |
| DEMO_SRC=apps/his-demo/dist/client | |
| DEMO_DST=apps/docs/build/demo | |
| mkdir -p "$DEMO_DST" | |
| cp -R "$DEMO_SRC"/. "$DEMO_DST"/ | |
| # GitHub Pages serves /demo/ → /demo/index.html (root-route SPA shell); | |
| # /demo/<deep-route> → /demo/404.html (which is the same SPA shell, so the | |
| # client-side router handles the deep route after hydration). | |
| cp "$DEMO_DST/_shell.html" "$DEMO_DST/index.html" | |
| cp "$DEMO_DST/_shell.html" "$DEMO_DST/404.html" | |
| echo "demo size: $(du -sh $DEMO_DST | cut -f1)" | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: apps/docs/build | |
| deploy: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| notify-search-engines: | |
| needs: deploy | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Ping IndexNow (Bing, Yandex) | |
| run: | | |
| set -euo pipefail | |
| KEY=00ead8a088444c033454e7c5d686592d | |
| HOST=awbx.github.io | |
| SITEMAP=https://awbx.github.io/fhir-dsl/sitemap.xml | |
| # Wait briefly for the deploy edge to flush, then extract URLs from sitemap. | |
| sleep 30 | |
| URLS=$(curl -sf "$SITEMAP" | grep -oE '<loc>[^<]+</loc>' | sed -E 's|</?loc>||g') | |
| if [ -z "$URLS" ]; then | |
| echo "No URLs found in sitemap; skipping IndexNow notify." | |
| exit 0 | |
| fi | |
| # Build the JSON payload (Bing IndexNow batch endpoint). | |
| URL_LIST=$(echo "$URLS" | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
| PAYLOAD=$(jq -n \ | |
| --arg host "$HOST" \ | |
| --arg key "$KEY" \ | |
| --arg keyLocation "https://$HOST/fhir-dsl/$KEY.txt" \ | |
| --argjson urls "$URL_LIST" \ | |
| '{host: $host, key: $key, keyLocation: $keyLocation, urlList: $urls}') | |
| echo "Notifying IndexNow with $(echo "$URL_LIST" | jq 'length') URLs." | |
| curl -sS -X POST "https://api.indexnow.org/IndexNow" \ | |
| -H "Content-Type: application/json; charset=utf-8" \ | |
| -H "Host: api.indexnow.org" \ | |
| --data "$PAYLOAD" \ | |
| -o /tmp/indexnow.txt -w "HTTP %{http_code}\n" || true | |
| cat /tmp/indexnow.txt 2>/dev/null || true |