-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (54 loc) · 2.07 KB
/
deploy-hf.yml
File metadata and controls
65 lines (54 loc) · 2.07 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
58
59
60
61
62
63
64
65
name: Deploy Backend to HuggingFace Spaces
on:
push:
branches: [main]
paths:
- 'Treasure_Hunt_Backend/**'
jobs:
deploy-to-hf:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Push to HuggingFace Spaces (Orphan Branch)
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE: ${{ secrets.HF_SPACE }}
run: |
# Configure git
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"
# Create a temporary directory with ONLY backend files
mkdir -p /tmp/hf-deploy
# Copy backend source (no node_modules, no .env, no uploads)
cp -r Treasure_Hunt_Backend/src /tmp/hf-deploy/src
cp Treasure_Hunt_Backend/package.json /tmp/hf-deploy/
cp Treasure_Hunt_Backend/package-lock.json /tmp/hf-deploy/
cp Treasure_Hunt_Backend/Dockerfile /tmp/hf-deploy/
cp Treasure_Hunt_Backend/.dockerignore /tmp/hf-deploy/
# Create HF-required README.md at root
cat > /tmp/hf-deploy/README.md << 'EOF'
---
title: Treasure Hunt Backend
emoji: 🏴☠️
colorFrom: green
colorTo: yellow
sdk: docker
pinned: false
---
Treasure Hunt 2026 — Backend API
EOF
# Remove leading whitespace from README (heredoc indent)
sed -i 's/^ //' /tmp/hf-deploy/README.md
# Initialize fresh orphan repo (no history = no large file issues)
cd /tmp/hf-deploy
git init
git checkout --orphan main
git add .
git commit -m "Deploy backend $(date +'%Y-%m-%d %H:%M')"
# Push to HuggingFace Space
git remote add hf https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_SPACE}
git push hf main --force
echo "✅ Deployed to https://huggingface.co/spaces/${HF_SPACE}"