-
Notifications
You must be signed in to change notification settings - Fork 0
57 lines (48 loc) · 1.76 KB
/
Copy pathdeploy.yml
File metadata and controls
57 lines (48 loc) · 1.76 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: Deploy to Cloudflare Workers
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: 24
cache: npm
- run: npm ci
- name: Create KV namespace if needed
run: |
KV_ID=$(npx wrangler kv namespace list 2>/dev/null | python3 -c "
import sys, json
namespaces = json.load(sys.stdin)
for ns in namespaces:
if 'CATALOG_KV' in ns.get('title',''):
print(ns['id'])
break
" 2>/dev/null || true)
if [ -z "$KV_ID" ]; then
KV_ID=$(npx wrangler kv namespace create CATALOG_KV 2>&1 | grep 'id = ' | sed 's/.*id = "\([^"]*\)".*/\1/')
echo "Created new KV namespace: $KV_ID"
fi
echo "KV_ID=$KV_ID"
echo "KV_ID=$KV_ID" >> $GITHUB_ENV
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Update wrangler.toml with KV ID
run: sed -i "s/PLACEHOLDER_KV_ID/${{ env.KV_ID }}/" wrangler.toml
- name: Set CNB_NPM_TOKEN as Worker Secret
run: echo "${{ secrets.CNB_NPM_TOKEN }}" | npx wrangler secret put CNB_NPM_TOKEN
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- run: npx wrangler deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
- name: Trigger catalog refresh
run: |
sleep 3
curl -sf -X POST \
-H "Authorization: Bearer ${{ secrets.CNB_NPM_TOKEN }}" \
"https://gameframex.upm.alianblank.uk/-/refresh" || echo "Refresh failed, cron will populate on next run"