gary-boon Claude commited on
Commit
8b77dd5
Β·
1 Parent(s): 5aed1a9

Add GitHub Action to deploy to both CPU and GPU HuggingFace Spaces

Browse files

- Deploy to CPU Space (visualisable-ai/api)
- Deploy to GPU Space (visualisable-ai/api-gpu)
- Runs automatically on push to main branch
- Provides deployment summary

This ensures both spaces stay in sync with latest backend code

πŸ€– Generated with Claude Code (https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

.github/workflows/deploy-to-huggingface.yml ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Deploy to HuggingFace Spaces
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ deploy-to-cpu-space:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v3
13
+ with:
14
+ fetch-depth: 0
15
+ lfs: true
16
+
17
+ - name: Push to CPU HuggingFace Space
18
+ env:
19
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
20
+ run: |
21
+ # Add HuggingFace CPU Space as remote (visualisable-ai/api)
22
+ git remote add hf-cpu https://huggingface.co/spaces/visualisable-ai/api
23
+
24
+ # Configure git with HF token
25
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
26
+ git config --global user.name "github-actions[bot]"
27
+
28
+ # Push to CPU Space
29
+ git push https://visualisable-ai:$HF_TOKEN@huggingface.co/spaces/visualisable-ai/api main --force
30
+
31
+ echo "βœ… Deployed to CPU HuggingFace Space (visualisable-ai/api)"
32
+
33
+ deploy-to-gpu-space:
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - uses: actions/checkout@v3
37
+ with:
38
+ fetch-depth: 0
39
+ lfs: true
40
+
41
+ - name: Push to GPU HuggingFace Space
42
+ env:
43
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
44
+ run: |
45
+ # Add HuggingFace GPU Space as remote (visualisable-ai/api-gpu)
46
+ git remote add hf-gpu https://huggingface.co/spaces/visualisable-ai/api-gpu
47
+
48
+ # Configure git with HF token
49
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
50
+ git config --global user.name "github-actions[bot]"
51
+
52
+ # Push to GPU Space
53
+ git push https://visualisable-ai:$HF_TOKEN@huggingface.co/spaces/visualisable-ai/api-gpu main --force
54
+
55
+ echo "βœ… Deployed to GPU HuggingFace Space (visualisable-ai/api-gpu)"
56
+
57
+ notify:
58
+ needs: [deploy-to-cpu-space, deploy-to-gpu-space]
59
+ runs-on: ubuntu-latest
60
+ if: always()
61
+ steps:
62
+ - name: Deployment Summary
63
+ run: |
64
+ echo "## HuggingFace Deployment Summary" >> $GITHUB_STEP_SUMMARY
65
+ echo "" >> $GITHUB_STEP_SUMMARY
66
+ echo "- CPU Space: ${{ needs.deploy-to-cpu-space.result }}" >> $GITHUB_STEP_SUMMARY
67
+ echo "- GPU Space: ${{ needs.deploy-to-gpu-space.result }}" >> $GITHUB_STEP_SUMMARY
68
+ echo "" >> $GITHUB_STEP_SUMMARY
69
+
70
+ if [ "${{ needs.deploy-to-cpu-space.result }}" = "success" ]; then
71
+ echo "βœ… CPU Space deployed successfully" >> $GITHUB_STEP_SUMMARY
72
+ else
73
+ echo "❌ CPU Space deployment failed" >> $GITHUB_STEP_SUMMARY
74
+ fi
75
+
76
+ if [ "${{ needs.deploy-to-gpu-space.result }}" = "success" ]; then
77
+ echo "βœ… GPU Space deployed successfully" >> $GITHUB_STEP_SUMMARY
78
+ else
79
+ echo "❌ GPU Space deployment failed" >> $GITHUB_STEP_SUMMARY
80
+ fi