Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 42 additions & 52 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy
name: Deploy

on:
push:
Expand All @@ -15,57 +15,75 @@ concurrency:
cancel-in-progress: true

jobs:
ci:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v4
- uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
- uses: actions/setup-node@v4
with:
node-version: "24"
cache: "pnpm"

- name: Install dependencies
run: pnpm install
- run: pnpm install --frozen-lockfile

- name: Check code
run: pnpm check

- name: Check types
run: pnpm check:types

test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 10

- uses: actions/setup-node@v4
with:
node-version: "24"
cache: "pnpm"

- run: pnpm install --frozen-lockfile

- name: Tests
run: pnpm test

build-and-deploy:
needs: [lint, test]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v4
with:
version: 10

- uses: actions/setup-node@v4
with:
node-version: "24"
cache: "pnpm"

- run: pnpm install --frozen-lockfile

- name: Build
run: pnpm build
env:
SPEC_PAT: ${{ secrets.SPEC_PAT }}

- name: Smoke test (wrangler dev)
run: |
# ──────────────────────────────────────────────────────────
# To reproduce locally:
# pnpm build
# pnpm wrangler:dev &
# curl -s -o /dev/null -w '%{http_code}' http://localhost:8788/quickstart/tempoctl -H 'Accept: text/html'
# curl -s -o /dev/null -w '%{http_code}' http://localhost:8788/ -H 'Accept: text/html'
# curl -s -o /dev/null -w '%{http_code}' http://localhost:8788/ -H 'Accept: text/markdown'
# All three should return 200. If any return 500, check wrangler
# logs for the error — usually a missing module or unsupported
# Node.js API. Fix in scripts/patch-cf.ts.
# ──────────────────────────────────────────────────────────

WRANGLER_LOG=$(mktemp)
npx wrangler dev --port 8788 > "$WRANGLER_LOG" 2>&1 &
pnpm exec wrangler dev --port 8788 > "$WRANGLER_LOG" 2>&1 &
WRANGLER_PID=$!

# Wait for wrangler to be ready (up to 30s)
for i in $(seq 1 30); do
if curl -sf http://localhost:8788/ -o /dev/null 2>/dev/null; then
break
Expand Down Expand Up @@ -115,34 +133,6 @@ jobs:
- name: Prune server bundle
run: node --experimental-strip-types scripts/prune-server.ts

- name: Upload build
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/

deploy:
needs: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 10

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "22"

- name: Download build
uses: actions/download-artifact@v4
with:
name: dist
path: dist/

- name: Sanitize branch name
if: github.event_name == 'pull_request'
id: branch
Expand All @@ -166,15 +156,15 @@ jobs:
script: |
const alias = "${{ steps.branch.outputs.alias }}"
const url = `https://${alias}-mpp-docs.porto.workers.dev`
const body = `MPP Docs preview: ${url}`
const body = `docs preview: ${url}`
const { data: comments } = await github.rest.issues.listComments({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
})
let existing = null
for (const comment of comments) {
if (comment.body && comment.body.startsWith('MPP Docs preview:')) {
if (comment.body && comment.body.startsWith('docs preview:')) {
existing = comment
break
}
Expand Down