sitcod3 commited on
Commit
13be860
·
verified ·
1 Parent(s): 708a341

Upload folder using huggingface_hub

Browse files
.github/workflows/deploy-huggingface.yml ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to Hugging Face Space (Docker)
2
+
3
+ # Pushes this repo to the HF Docker Space on every push to main.
4
+ # HF builds the image server-side from ./Dockerfile (app_port 7860).
5
+ #
6
+ # PREREQUISITE: create the Space first (huggingface.co/new-space > Docker SDK,
7
+ # name it e.g. BRIDGE_Modul-E_prod), then:
8
+ #
9
+ # Required setup (one-time, in GitHub > Settings > Secrets and variables):
10
+ # Secrets > Actions > New repository secret:
11
+ # HF_TOKEN = a Hugging Face write token (https://huggingface.co/settings/tokens)
12
+ # Variables > Actions > New repository variable:
13
+ # HF_SPACE_ID = e.g. sitcod3/BRIDGE_Modul-E_prod
14
+ #
15
+ # Space secrets (set in the Space > Settings > Variables and secrets):
16
+ # VITE_SUPABASE_URL, VITE_SUPABASE_ANON_KEY (as build-time secrets so the
17
+ # Vite bundle is baked with them), SUPABASE_SERVICE_ROLE_KEY,
18
+ # OPENROUTER_API_KEY, UPSTASH_REDIS_REST_URL, UPSTASH_REDIS_REST_TOKEN
19
+
20
+ on:
21
+ push:
22
+ branches:
23
+ - main
24
+ workflow_dispatch:
25
+
26
+ env:
27
+ HF_SPACE_ID: ${{ vars.HF_SPACE_ID || 'sitcod3/BRIDGE_Modul-E_prod' }}
28
+
29
+ jobs:
30
+ deploy:
31
+ runs-on: ubuntu-latest
32
+ steps:
33
+ - name: Checkout repository
34
+ uses: actions/checkout@v4
35
+ with:
36
+ fetch-depth: 0
37
+ lfs: true
38
+
39
+ - name: Push to Hugging Face Space
40
+ env:
41
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
42
+ run: |
43
+ if [ -z "$HF_TOKEN" ]; then
44
+ echo "::error::HF_TOKEN secret is not set (GitHub > Settings > Secrets and variables > Actions)"
45
+ exit 1
46
+ fi
47
+ mkdir -p hf-space
48
+ # Ship tracked files only (excludes node_modules, dist, .git, local .env)
49
+ git archive HEAD | tar -x -C hf-space
50
+ cd hf-space
51
+ git config --global user.email "ci@fortydn.lab"
52
+ git config --global user.name "FortyDN CI/CD"
53
+ git init -b main
54
+ git add .
55
+ git commit -m "Deploy from GitHub Actions - $(date +'%Y-%m-%d %H:%M:%S')"
56
+ HF_REMOTE="https://sitcod3:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE_ID}"
57
+ for i in 1 2 3; do
58
+ if git push --force "$HF_REMOTE" main; then
59
+ echo "Push succeeded on attempt $i"
60
+ break
61
+ fi
62
+ echo "Push attempt $i failed, retrying in 10s..."
63
+ sleep 10
64
+ if [ "$i" = "3" ]; then
65
+ echo "::error::Failed to push to Hugging Face Space after 3 attempts"
66
+ exit 1
67
+ fi
68
+ done
69
+
70
+ - name: Verify Space is Running
71
+ env:
72
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
73
+ run: |
74
+ for i in $(seq 1 12); do
75
+ STAGE=$(curl -s -H "Authorization: Bearer ${HF_TOKEN}" \
76
+ "https://huggingface.co/api/spaces/${HF_SPACE_ID}" | \
77
+ grep -o '"stage":"[A-Z_]*"' | head -1 | cut -d'"' -f4 || echo "UNKNOWN")
78
+ echo "Attempt $i: Space stage = $STAGE"
79
+ if [ "$STAGE" = "RUNNING" ]; then
80
+ echo "Space is RUNNING"
81
+ break
82
+ fi
83
+ sleep 10
84
+ done
85
+
86
+ - name: Smoke-test the live API
87
+ env:
88
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
89
+ run: |
90
+ HOST=$(curl -s -H "Authorization: Bearer ${HF_TOKEN}" \
91
+ "https://huggingface.co/api/spaces/${HF_SPACE_ID}" | \
92
+ grep -o '"host":"[^"]*"' | head -1 | cut -d'"' -f4 || true)
93
+ echo "Space host: $HOST"
94
+ if [ -n "$HOST" ]; then
95
+ echo "--- /api/health ---"
96
+ curl -s -m 20 "$HOST/api/health" || echo "(health check unreachable - Space may still be building)"
97
+ fi
assets/.aistudio/.gitignore ADDED
@@ -0,0 +1 @@
 
 
1
+ *