Repository navigation
57 lines (54 loc) · 2.06 KB
/
Copy pathhosted-build.yml
File metadata and controls
57 lines (54 loc) · 2.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: Vercel build
# Builds the hosted service the way Vercel does (same CLI, same project
# settings) on every PR that touches it, so a broken build fails here
# instead of after merge. Needs no secrets.
on:
pull_request:
paths:
- hosted/**
- src/card.js
- .github/workflows/hosted-build.yml
- .github/workflows/hosted-deploy.yml
- test/hosted-*.test.js
permissions:
contents: read
jobs:
build:
name: Vercel build (hosted)
runs-on: ubuntu-latest
timeout-minutes: 10
env:
VERCEL_TELEMETRY_DISABLED: "1"
steps:
- name: Harden runner
uses: step-security/harden-runner@e14015d583714f6e62063499dc959a02595150a1 # v2.21.1
with:
egress-policy: audit
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
persist-credentials: false
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22
- name: Install dependencies
run: npm ci --omit=dev
- name: Test hosted service
run: node --test test/hosted-*.test.js
- name: Write Vercel project settings (mirrors the live project)
run: |
mkdir -p .vercel
cat > .vercel/project.json <<'JSON'
{"projectId":"ci","orgId":"ci","settings":{"framework":null,"rootDirectory":"hosted","nodeVersion":"22.x","buildCommand":null,"outputDirectory":null,"installCommand":null,"devCommand":null}}
JSON
- name: Vercel build
run: npx --yes vercel@59.25.4 build --prod
- name: Check build output
run: |
set -euo pipefail
out=.vercel/output
find "$out/static" "$out/functions" -maxdepth 2 | sort
test -f "$out/static/index.html"
if [ -e "$out/static/lib" ]; then echo "::error::hosted/lib is in the static output and would be public"; exit 1; fi
for fn in card health ingest register revoke; do
test -d "$out/functions/api/$fn.func" || { echo "::error::missing function api/$fn"; exit 1; }
done