Skip to content

Commit 2fb2d5e

Browse files
ci: rewrite deploy workflow to use Deno Deploy REST API directly (no CLI)
1 parent 5aca55e commit 2fb2d5e

1 file changed

Lines changed: 55 additions & 12 deletions

File tree

.github/workflows/deploy-kilo-proxy.yml

Lines changed: 55 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,62 @@ jobs:
1515
steps:
1616
- uses: actions/checkout@v4
1717

18-
- name: Install Deno
19-
uses: denoland/setup-deno@v2
20-
with:
21-
deno-version: v2.x
22-
23-
- name: Deploy via deployctl (create if missing)
18+
- name: Deploy via Deno Deploy REST API
2419
env:
2520
DENO_DEPLOY_TOKEN: ${{ secrets.DENO_DEPLOY_TOKEN }}
2621
run: |
2722
set -e
28-
deno run -A jsr:@deno/deployctl deploy \
29-
--project=screenoperator-kilo-proxy \
30-
--token="$DENO_DEPLOY_TOKEN" \
31-
--no-static \
32-
--create \
33-
cloudflare-worker/kilo-proxy/kilo_proxy.ts
23+
24+
APP_NAME="screenoperator-kilo-proxy"
25+
SOURCE_FILE="cloudflare-worker/kilo-proxy/kilo_proxy.ts"
26+
DENO_API="https://api.deno.com/v1"
27+
28+
# 1. Get org slug from token
29+
ORG=$(curl -sf -H "Authorization: Bearer $DENO_DEPLOY_TOKEN" \
30+
"$DENO_API/user" | python3 -c "
31+
import sys,json
32+
u=json.load(sys.stdin)
33+
orgs=u.get('organizations',[])
34+
print(orgs[0]['name'] if orgs else u.get('name',''))
35+
")
36+
echo "Org: $ORG"
37+
38+
# 2. Create app (ignore 409 conflict = already exists)
39+
HTTP=$(curl -s -o /dev/null -w "%{http_code}" \
40+
-X POST "$DENO_API/organizations/$ORG/projects" \
41+
-H "Authorization: Bearer $DENO_DEPLOY_TOKEN" \
42+
-H "Content-Type: application/json" \
43+
-d "{\"name\":\"$APP_NAME\"}")
44+
echo "Create app HTTP: $HTTP"
45+
46+
# 3. Read source file and build assets payload
47+
CODE=$(cat "$SOURCE_FILE")
48+
PAYLOAD=$(python3 -c "
49+
import json, sys
50+
code = open('$SOURCE_FILE').read()
51+
assets = {
52+
'main.ts': {
53+
'kind': 'file',
54+
'content': code,
55+
'encoding': 'utf-8'
56+
}
57+
}
58+
print(json.dumps({
59+
'entryPointUrl': 'main.ts',
60+
'assets': assets,
61+
'envVars': {}
62+
}))
63+
")
64+
65+
# 4. Deploy
66+
RESULT=$(curl -sf -X POST "$DENO_API/projects/$APP_NAME/deployments" \
67+
-H "Authorization: Bearer $DENO_DEPLOY_TOKEN" \
68+
-H "Content-Type: application/json" \
69+
-d "$PAYLOAD")
70+
echo "Deploy result: $RESULT"
71+
echo "$RESULT" | python3 -c "
72+
import sys,json
73+
d=json.load(sys.stdin)
74+
domains=d.get('domains',[])
75+
print('Deployed to:', domains[0] if domains else 'check dashboard')
76+
"

0 commit comments

Comments
 (0)