clone

a deno framework for local-first web apps that open instantly, work offline and sync when users choose

feat/184-task-notice-migration
lofi / .github / workflows / demo.yml
demo.yml 4.6K
1name: Demo deploy23# Deploys demo.lofi.host: the starter app generated by the real `create`4# command from the exact published JSR version, with the checked-in demo5# overlay (apps/demo/overlay) applied before the build. Runs after each6# successful publish; the dispatch input redeploys any published version7# without cutting a release.89on:10 workflow_run:11 workflows: ["Publish to JSR"]12 types: [completed]13 workflow_dispatch:14 inputs:15 version:16 description: "Published @nzip/lofi version (e.g. 0.8.0)"17 required: true1819permissions:20 contents: read2122concurrency:23 group: demo-deploy24 cancel-in-progress: false2526jobs:27 deploy:28 if: github.event_name == 'workflow_dispatch' || github.event.workflow_run.conclusion == 'success'29 runs-on: ubuntu-latest30 # the Cloudflare credentials live as secrets on the `dev` environment; a job31 # must declare that environment for them to resolve32 environment:33 name: dev34 url: https://demo.lofi.host35 steps:36 - uses: actions/checkout@v437 - uses: denoland/setup-deno@v238 with:39 deno-version: v2.x4041 # A tag-triggered publish run reports its tag as head_branch.42 - name: Resolve released version43 id: version44 env:45 DISPATCH_VERSION: ${{ inputs.version }}46 RUN_HEAD_BRANCH: ${{ github.event.workflow_run.head_branch }}47 run: |48 if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then49 version="$DISPATCH_VERSION"50 else51 version="${RUN_HEAD_BRANCH#v}"52 fi53 if ! printf '%s' "$version" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$'; then54 echo "::error::cannot resolve a release version from '$version'"55 exit 156 fi57 echo "version=$version" >> "$GITHUB_OUTPUT"5859 - name: Wait for JSR availability60 run: |61 v="${{ steps.version.outputs.version }}"62 for attempt in $(seq 1 30); do63 if curl -fsS --max-time 10 https://jsr.io/@nzip/lofi/meta.json \64 | jq -e --arg v "$v" '.versions[$v]' > /dev/null; then65 exit 066 fi67 sleep 1068 done69 echo "::error::@nzip/lofi@$v is not visible on JSR"70 exit 17172 # Generated outside the checkout so the repository import map cannot73 # shadow the published package.74 - name: Generate the demo app from the published package75 working-directory: ${{ runner.temp }}76 run: |77 deno run -A --minimum-dependency-age=0 \78 "jsr:@nzip/lofi@${{ steps.version.outputs.version }}/create" demo-app7980 - name: Apply the demo overlay81 run: |82 deno run -A tools/demo_overlay.ts \83 --app "${{ runner.temp }}/demo-app" \84 --version "${{ steps.version.outputs.version }}"8586 # The publish quarantine also applies to the generated project's own87 # dependency resolution; prime the cache the way tools/golden.ts does.88 - name: Prime the registry cache89 working-directory: ${{ runner.temp }}/demo-app90 run: |91 jq -r '.imports | to_entries[]92 | select(.key == "@nzip/lofi" or (.key | startswith("@nzip/lofi/")))93 | select(.key | endswith("/") | not) | .value' deno.json \94 | sort -u | xargs deno cache --minimum-dependency-age=09596 - name: Doctor97 working-directory: ${{ runner.temp }}/demo-app98 run: deno task doctor99100 - name: Build101 working-directory: ${{ runner.temp }}/demo-app102 run: deno task build103104 # Pages consumes _headers, so the CSP the build documents in105 # _headers.example ships as a real response header on the demo.106 - name: Promote the CSP header snippet107 working-directory: ${{ runner.temp }}/demo-app108 run: |109 if [ -f dist/_headers.example ]; then110 cp dist/_headers.example dist/_headers111 fi112113 # wrangler runs via npx (npm cache) rather than wrangler-action: the action114 # installs wrangler with `npm i` into the checkout, and npm cannot graft115 # onto the Deno-managed node_modules layout at the repo root.116 - name: Deploy to Cloudflare Pages117 env:118 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}119 CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}120 run: |121 if ! npx --yes wrangler@4 pages project list | grep -q "demo-lofi-host"; then122 npx --yes wrangler@4 pages project create demo-lofi-host --production-branch=main123 fi124 npx --yes wrangler@4 pages deploy "${{ runner.temp }}/demo-app/dist" \125 --project-name=demo-lofi-host --branch=main