Commit e015b87f17

e015b87f1701bce0361140b75d471cf1d9b28dee

parent: 592f79be7b

Unsigned

Alicia Sykes <alicia@omg.lol> ยท 2026-06-07 20:00 UTC

CI and deployment workflows for API

Layout: unified ยท split

.github/workflows/ci-api.yml added +216
@@ -0,0 +1,216 @@
1# CI checks for the API, run on PRs touching api/ and manually via dispatch
2name: ๐Ÿšฆ API CI
3
4on:
5 pull_request:
6 paths:
7 - 'api/**'
8 - 'awesome-privacy.yml'
9 - '.github/workflows/ci-api.yml'
10 workflow_dispatch:
11
12permissions:
13 contents: read
14
15concurrency:
16 group: ${{ github.workflow }}-${{ github.ref }}
17 cancel-in-progress: true
18
19jobs:
20 lint:
21 name: ๐Ÿ›ก๏ธ Lint
22 runs-on: ubuntu-latest
23 defaults:
24 run:
25 working-directory: api
26 steps:
27 - uses: actions/checkout@v6
28 with:
29 persist-credentials: false
30 - uses: oven-sh/setup-bun@v2
31 with:
32 bun-version: latest
33 - run: bun install --frozen-lockfile
34 - run: bun run lint
35
36 format:
37 name: ๐Ÿ’… Format
38 runs-on: ubuntu-latest
39 defaults:
40 run:
41 working-directory: api
42 steps:
43 - uses: actions/checkout@v6
44 with:
45 persist-credentials: false
46 - uses: oven-sh/setup-bun@v2
47 with:
48 bun-version: latest
49 - run: bun install --frozen-lockfile
50 - run: bun run format:check
51
52 typecheck:
53 name: ๐Ÿงฉ Typecheck
54 runs-on: ubuntu-latest
55 defaults:
56 run:
57 working-directory: api
58 steps:
59 - uses: actions/checkout@v6
60 with:
61 persist-credentials: false
62 - uses: oven-sh/setup-bun@v2
63 with:
64 bun-version: latest
65 - run: bun install --frozen-lockfile
66 - run: bun run build:data
67 - run: bun run typecheck
68
69 test:
70 name: ๐Ÿงช Test
71 runs-on: ubuntu-latest
72 defaults:
73 run:
74 working-directory: api
75 steps:
76 - uses: actions/checkout@v6
77 with:
78 persist-credentials: false
79 - uses: oven-sh/setup-bun@v2
80 with:
81 bun-version: latest
82 - run: bun install --frozen-lockfile
83 - run: bun run build:data
84 - run: bun run test
85
86 build:
87 name: ๐Ÿ—๏ธ Build
88 runs-on: ubuntu-latest
89 defaults:
90 run:
91 working-directory: api
92 steps:
93 - uses: actions/checkout@v6
94 with:
95 persist-credentials: false
96 - uses: oven-sh/setup-bun@v2
97 with:
98 bun-version: latest
99 - run: bun install --frozen-lockfile
100 - run: bun run build
101 - name: Verify bundle output
102 run: test -f dist/index.workers.js || { echo "โŒ worker bundle not produced"; exit 1; }
103
104 smoke:
105 name: ๐Ÿ’จ Smoke Test
106 runs-on: ubuntu-latest
107 defaults:
108 run:
109 working-directory: api
110 steps:
111 - uses: actions/checkout@v6
112 with:
113 persist-credentials: false
114 - uses: oven-sh/setup-bun@v2
115 with:
116 bun-version: latest
117 - run: bun install --frozen-lockfile
118 - run: bun run smoke
119
120 docker-smoke:
121 name: ๐Ÿณ Docker Smoke
122 runs-on: ubuntu-latest
123 continue-on-error: true
124 defaults:
125 run:
126 working-directory: api
127 steps:
128 - uses: actions/checkout@v6
129 with:
130 persist-credentials: false
131 - name: Build and run container
132 run: bash tests/docker-smoke.sh
133 timeout-minutes: 10
134
135 dependency-review:
136 name: ๐Ÿ”’ Dependency Audit
137 runs-on: ubuntu-latest
138 if: github.event_name == 'pull_request'
139 steps:
140 - uses: actions/checkout@v6
141 with:
142 persist-credentials: false
143 - uses: actions/dependency-review-action@v5
144 with:
145 fail-on-severity: moderate
146
147 secret-scan:
148 name: ๐Ÿ”‘ Secret Scan
149 runs-on: ubuntu-latest
150 if: github.event_name == 'pull_request'
151 steps:
152 - uses: actions/checkout@v6
153 with:
154 fetch-depth: 0
155 persist-credentials: false
156 - name: Scan PR diff for secrets
157 uses: trufflesecurity/trufflehog@v3.95.5
158 with:
159 base: ${{ github.event.pull_request.base.sha }}
160 head: ${{ github.event.pull_request.head.sha }}
161 extra_args: --only-verified
162
163 # Renders a markdown table of every check at the end
164 summary:
165 name: ๐Ÿ“‹ Summary
166 runs-on: ubuntu-latest
167 if: always()
168 continue-on-error: true
169 needs:
170 - lint
171 - format
172 - typecheck
173 - test
174 - build
175 - smoke
176 - docker-smoke
177 - dependency-review
178 - secret-scan
179 steps:
180 - name: Render summary
181 env:
182 NEEDS: ${{ toJSON(needs) }}
183 run: |
184 label() {
185 case "$1" in
186 lint) echo "๐Ÿ›ก๏ธ Lint" ;;
187 format) echo "๐Ÿ’… Format" ;;
188 typecheck) echo "๐Ÿงฉ Typecheck" ;;
189 test) echo "๐Ÿงช Test" ;;
190 build) echo "๐Ÿ—๏ธ Build" ;;
191 smoke) echo "๐Ÿ’จ Smoke Test" ;;
192 docker-smoke) echo "๐Ÿณ Docker Smoke" ;;
193 dependency-review) echo "๐Ÿ”’ Dependency Audit" ;;
194 secret-scan) echo "๐Ÿ”‘ Secret Scan" ;;
195 *) echo "$1" ;;
196 esac
197 }
198 status() {
199 case "$1" in
200 success) echo "โœ… Passed" ;;
201 skipped) echo "โญ๏ธ Skipped" ;;
202 cancelled) echo "๐Ÿšซ Cancelled" ;;
203 failure) [ "$2" = docker-smoke ] && echo "โš ๏ธ Warnings" || echo "โŒ Failed" ;;
204 *) echo "โ” $1" ;;
205 esac
206 }
207 {
208 echo "## API CI Summary"
209 echo ""
210 echo "| Check | Status |"
211 echo "|-------|--------|"
212 } >> "$GITHUB_STEP_SUMMARY"
213 for job in $(echo "$NEEDS" | jq -r 'keys[]'); do
214 result=$(echo "$NEEDS" | jq -r --arg j "$job" '.[$j].result')
215 echo "| $(label "$job") | $(status "$result" "$job") |" >> "$GITHUB_STEP_SUMMARY"
216 done
.github/workflows/deploy.yml added +57
@@ -0,0 +1,57 @@
1name: ๐Ÿš€ Deploy API
2
3on:
4 push:
5 branches: [main]
6 paths:
7 - 'api/**'
8 - 'awesome-privacy.yml'
9 - '.github/workflows/deploy.yml'
10 workflow_dispatch:
11
12permissions:
13 contents: read
14
15concurrency:
16 group: deploy-api-${{ github.ref }}
17 cancel-in-progress: false
18
19jobs:
20 checks:
21 name: ๐Ÿงช Checks
22 runs-on: ubuntu-latest
23 defaults:
24 run:
25 working-directory: api
26 steps:
27 - uses: actions/checkout@v6
28 with:
29 persist-credentials: false
30 - uses: oven-sh/setup-bun@v2
31 with:
32 bun-version: latest
33 - run: bun install --frozen-lockfile
34 - run: bun run build:data
35 - run: bun run lint
36 - run: bun run test
37
38 deploy:
39 name: โ˜๏ธ Deploy to Cloudflare
40 needs: checks
41 runs-on: ubuntu-latest
42 defaults:
43 run:
44 working-directory: api
45 steps:
46 - uses: actions/checkout@v6
47 with:
48 persist-credentials: false
49 - uses: oven-sh/setup-bun@v2
50 with:
51 bun-version: latest
52 - run: bun install --frozen-lockfile
53 - name: Build data and deploy worker
54 env:
55 CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
56 CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
57 run: bun run deploy