Skip to content

Commit d0c7e3f

Browse files
feat: add GitHub Actions workflow for Firebase Auth proxy
1 parent a74137c commit d0c7e3f

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Deploy Firebase Auth Proxy to Deno Deploy
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
paths:
7+
- 'cloudflare-worker/firebase-auth-proxy/firebase_auth_proxy.ts'
8+
- 'cloudflare-worker/firebase-auth-proxy/deno.json'
9+
- '.github/workflows/deploy-firebase-auth-proxy.yml'
10+
11+
jobs:
12+
deploy:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: read
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
20+
- name: Install Deno
21+
uses: denoland/setup-deno@v2
22+
with:
23+
deno-version: 2.4.5
24+
25+
- name: Deploy to Deno Deploy
26+
env:
27+
DENO_DEPLOY_TOKEN: ${{ secrets.DENO_DEPLOY_TOKEN }}
28+
run: |
29+
set -euo pipefail
30+
31+
ORG="android-poweruser"
32+
APP="screenoperator-firebase-auth-proxy"
33+
SRC_DIR="cloudflare-worker/firebase-auth-proxy"
34+
ENTRYPOINT="firebase_auth_proxy.ts"
35+
API="https://console.deno.com/api/v2"
36+
AUTH="Authorization: Bearer $DENO_DEPLOY_TOKEN"
37+
38+
cd "$SRC_DIR"
39+
40+
echo "=== Current apps in org (diagnostic) ==="
41+
curl -sS -H "$AUTH" "$API/apps" | head -c 1500; echo
42+
echo "=== GET app $APP ==="
43+
GET_CODE=$(curl -sS -o /tmp/app.json -w '%{http_code}' -H "$AUTH" "$API/apps/$APP" || echo 000)
44+
echo "GET -> $GET_CODE"
45+
echo "--- app body ---"; head -c 1500 /tmp/app.json 2>/dev/null; echo
46+
RT=$(cat /tmp/app.json 2>/dev/null | python3 -c "
47+
import json,sys
48+
try:
49+
a=json.load(sys.stdin)
50+
cfg=a.get('config') or a.get('app',{}).get('config') or {}
51+
rt=cfg.get('runtime',{}) if isinstance(cfg,dict) else {}
52+
print(rt.get('type','') + '|' + str(rt.get('entrypoint','')))
53+
except Exception:
54+
print('|')
55+
" 2>/dev/null || echo "|")
56+
RT_TYPE="${RT%%|*}"; RT_ENTRY="${RT#*|}"
57+
echo "Parsed: runtime='${RT_TYPE}' entrypoint='${RT_ENTRY}'"
58+
if [ "$GET_CODE" = "200" ] && { [ "$RT_TYPE" = "static" ] || [ "$RT_TYPE" != "dynamic" ] || [ "$RT_ENTRY" != "$ENTRYPOINT" ]; }; then
59+
echo "App exists but wrong config. Deleting." DEL_CODE=$(curl -sS -o /tmp/del.out -w '%{http_code}' -X DELETE -H "$AUTH" "$API/apps/$APP" || echo 000)
60+
echo "DELETE -> $DEL_CODE"; head -c 400 /tmp/del.out 2>/dev/null; echo
61+
for w in 1 2 3 4 5 6; do
62+
sleep 5
63+
G2=$(curl -sS -o /dev/null -w '%{http_code}' -H "$AUTH" "$API/apps/$APP" || echo 000)
64+
echo "post-delete GET attempt $w: $G2"
65+
[ "$G2" = "404" ] && break
66+
done
67+
fi
68+
69+
deno deploy create --org="$ORG" --app="$APP" --token="$DENO_DEPLOY_TOKEN" --source=local --do-not-use-detected-build-config --runtime-mode=dynamic --entrypoint="$ENTRYPOINT" --region=us . 2>&1 || echo "create skipped (app already exists)"
70+
71+
deno deploy --org="$ORG" --app="$APP" --token="$DENO_DEPLOY_TOKEN" --prod
72+
73+
- name: Verify proxy is alive
74+
run: |
75+
set -euo pipefail
76+
URL="https://screenoperator-firebase-auth-proxy.android-poweruser.deno.net/v1/accounts:signInAnonymously?key=test"
77+
78+
for i in 1 2 3 4 5 6 7 8 9 10; do
79+
PRE=$(curl -s -o /dev/null -w '%{http_code}' -X OPTIONS "$URL" -H "Origin: https://android-poweruser.github.io" -H "Access-Control-Request-Method: POST" --max-time 20 || echo 000)
80+
echo "attempt $i: OPTIONS=$PRE"
81+
if [ "$PRE" = "200" ]; then
82+
echo "Proxy is live."
83+
exit 0
84+
fi
85+
sleep 10
86+
done
87+
88+
echo "::error::Proxy did not answer correctly."
89+
exit 1

0 commit comments

Comments
 (0)