|
| 1 | +name: Deploy Keystatic admin Worker |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + paths: |
| 7 | + - "apps/admin/**" |
| 8 | + - "package.json" |
| 9 | + - "pnpm-lock.yaml" |
| 10 | + - "pnpm-workspace.yaml" |
| 11 | + - ".github/workflows/deploy-admin.yml" |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: admin-worker-production |
| 19 | + cancel-in-progress: false |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + steps: |
| 25 | + - name: Check out trusted admin code |
| 26 | + uses: actions/checkout@v7 |
| 27 | + with: |
| 28 | + persist-credentials: false |
| 29 | + |
| 30 | + - name: Set up pnpm |
| 31 | + uses: pnpm/action-setup@v6 |
| 32 | + |
| 33 | + - name: Set up Node.js |
| 34 | + uses: actions/setup-node@v7 |
| 35 | + with: |
| 36 | + node-version: "22" |
| 37 | + cache: pnpm |
| 38 | + |
| 39 | + - name: Install dependencies |
| 40 | + run: pnpm install --frozen-lockfile |
| 41 | + |
| 42 | + - name: Type-check admin application |
| 43 | + run: pnpm --filter @preferredai/admin typecheck |
| 44 | + |
| 45 | + - name: Build admin Worker without deployment secrets |
| 46 | + env: |
| 47 | + KEYSTATIC_GITHUB_CLIENT_ID: build-placeholder |
| 48 | + KEYSTATIC_GITHUB_CLIENT_SECRET: build-placeholder |
| 49 | + KEYSTATIC_SECRET: 0000000000000000000000000000000000000000000000000000000000000000 |
| 50 | + NEXT_PUBLIC_KEYSTATIC_STORAGE_KIND: github |
| 51 | + NEXT_PUBLIC_KEYSTATIC_GITHUB_APP_SLUG: preferredai-keystatic |
| 52 | + run: pnpm --filter @preferredai/admin build:worker |
| 53 | + |
| 54 | + - name: Upload Worker bundle |
| 55 | + uses: actions/upload-artifact@v7 |
| 56 | + with: |
| 57 | + name: admin-worker |
| 58 | + path: | |
| 59 | + apps/admin/.open-next |
| 60 | + apps/admin/wrangler.jsonc |
| 61 | + include-hidden-files: true |
| 62 | + if-no-files-found: error |
| 63 | + retention-days: 3 |
| 64 | + |
| 65 | + deploy: |
| 66 | + needs: build |
| 67 | + runs-on: ubuntu-latest |
| 68 | + environment: |
| 69 | + name: admin-production |
| 70 | + url: https://admin.preferred.ai/keystatic |
| 71 | + steps: |
| 72 | + - name: Download Worker bundle |
| 73 | + uses: actions/download-artifact@v8 |
| 74 | + with: |
| 75 | + name: admin-worker |
| 76 | + path: admin-worker |
| 77 | + |
| 78 | + - name: Deploy editor-only Worker |
| 79 | + uses: cloudflare/wrangler-action@v4 |
| 80 | + with: |
| 81 | + apiToken: ${{ secrets.CLOUDFLARE_WORKERS_API_TOKEN }} |
| 82 | + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} |
| 83 | + workingDirectory: admin-worker |
| 84 | + packageManager: npm |
| 85 | + wranglerVersion: 4.124.0 |
| 86 | + command: deploy --config wrangler.jsonc --keep-vars |
| 87 | + |
| 88 | + - name: Smoke-test admin origin |
| 89 | + shell: bash |
| 90 | + run: | |
| 91 | + set -euo pipefail |
| 92 | + curl --fail --silent --show-error --location --retry 10 --retry-all-errors https://admin.preferred.ai/keystatic > /dev/null |
| 93 | + status="$(curl --silent --output /dev/null --write-out '%{http_code}' https://admin.preferred.ai/)" |
| 94 | + test "$status" = "307" -o "$status" = "308" |
0 commit comments