GitHub Actions commited on
Commit
ef27b0a
·
1 Parent(s): 4ab7df8

Deploy from GitHub Actions [stg] - 2025-10-31 07:10:00

Browse files
.github/actions/deploy-to-hf/action.yml ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: 'Deploy to Hugging Face Space'
2
+ description: 'Deploys application to Hugging Face Space'
3
+ inputs:
4
+ environment:
5
+ description: 'Environment name (dev, test, stg, prod)'
6
+ required: true
7
+ branch:
8
+ description: 'Branch name'
9
+ required: true
10
+ hf-username:
11
+ description: 'Hugging Face username'
12
+ required: true
13
+ hf-token:
14
+ description: 'Hugging Face token'
15
+ required: true
16
+ hf-space-name:
17
+ description: 'Hugging Face Space name'
18
+ required: true
19
+
20
+ runs:
21
+ using: 'composite'
22
+ steps:
23
+ - name: Setup Python for Hugging Face CLI
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: '3.9'
27
+
28
+ - name: Install Hugging Face Hub
29
+ shell: bash
30
+ run: |
31
+ pip install huggingface_hub
32
+ sudo apt-get update && sudo apt-get install -y rsync
33
+
34
+ - name: Validate secrets
35
+ shell: bash
36
+ run: |
37
+ echo "HF_USERNAME: ${{ inputs.hf-username }}"
38
+ echo "HF_SPACE_NAME: ${{ inputs.hf-space-name }}"
39
+ echo "Token length: ${#HF_TOKEN}"
40
+ env:
41
+ HF_TOKEN: ${{ inputs.hf-token }}
42
+
43
+ - name: Create Hugging Face Space README
44
+ shell: bash
45
+ env:
46
+ SPACE_NAME: ${{ inputs.hf-space-name }}
47
+ BRANCH_NAME: ${{ inputs.branch }}
48
+ ENVIRONMENT: ${{ inputs.environment }}
49
+ run: |
50
+ # Environment-specific settings
51
+ case "${ENVIRONMENT}" in
52
+ dev)
53
+ EMOJI="🧪"
54
+ COLOR_TO="yellow"
55
+ ENV_TITLE="Development"
56
+ ENV_DESC="🧪 **This is a development environment** - Features may be unstable"
57
+ ;;
58
+ test)
59
+ EMOJI="🧪"
60
+ COLOR_TO="gray"
61
+ ENV_TITLE="Mock/Testing"
62
+ ENV_DESC="🧪 **This is the mock/testing environment** - Feature branch deployment"
63
+ ;;
64
+ stg)
65
+ EMOJI="🧪"
66
+ COLOR_TO="indigo"
67
+ ENV_TITLE="Staging"
68
+ ENV_DESC="🚧 **This is a staging environment** - Pre-production testing"
69
+ ;;
70
+ prod)
71
+ EMOJI="🚀"
72
+ COLOR_TO="green"
73
+ ENV_TITLE="Production"
74
+ ENV_DESC="✅ **This is the production environment** - Stable and tested features"
75
+ ;;
76
+ esac
77
+
78
+ cat > README.md << EOF
79
+ ---
80
+ title: ${SPACE_NAME}
81
+ emoji: ${EMOJI}
82
+ colorFrom: pink
83
+ colorTo: ${COLOR_TO}
84
+ sdk: docker
85
+ app_port: 7860
86
+ pinned: false
87
+ license: mit
88
+ ---
89
+
90
+ # ${SPACE_NAME} (${ENV_TITLE})
91
+
92
+ ${ENV_DESC}
93
+
94
+ This is a Next.js application deployed to Hugging Face Spaces from the \`${BRANCH_NAME}\` branch.
95
+
96
+ ## Features
97
+
98
+ - Built with Next.js and React
99
+ - Containerized with Docker
100
+ - Automatic deployment from GitHub ${BRANCH_NAME} branch
101
+ - ${ENV_TITLE} environment
102
+
103
+ ## Development
104
+
105
+ To run locally:
106
+
107
+ \`\`\`bash
108
+ npm install
109
+ npm run dev
110
+ \`\`\`
111
+
112
+ The application will be available at http://localhost:3200
113
+
114
+ ---
115
+ **Branch**: ${BRANCH_NAME}
116
+ **Environment**: ${ENV_TITLE}
117
+ **Last Deploy**: $(date)
118
+ EOF
119
+
120
+ - name: Clone or update Hugging Face Space
121
+ shell: bash
122
+ env:
123
+ HF_USERNAME: ${{ inputs.hf-username }}
124
+ HF_TOKEN: ${{ inputs.hf-token }}
125
+ HF_SPACE_NAME: ${{ inputs.hf-space-name }}
126
+ run: |
127
+ # Skip LFS for initial clone to avoid errors
128
+ export GIT_LFS_SKIP_SMUDGE=1
129
+
130
+ # Try to clone the space with authentication
131
+ if git clone https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf-space; then
132
+ echo "✅ Space exists, updating..."
133
+ cd hf-space
134
+ # Reset any failed LFS state
135
+ git lfs install --skip-smudge
136
+ else
137
+ echo "🆕 Creating new space..."
138
+ # Create space using Python API (more reliable)
139
+ python3 -c "import os; from huggingface_hub import HfApi; api = HfApi(token=os.environ['HF_TOKEN']); api.create_repo(repo_id=f\"{os.environ['HF_USERNAME']}/{os.environ['HF_SPACE_NAME']}\", repo_type='space', space_sdk='docker')" 2>&1 || echo "Space creation failed or already exists"
140
+ sleep 5
141
+ git clone https://user:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf-space
142
+ cd hf-space
143
+ fi
144
+
145
+ - name: Copy files to Hugging Face Space
146
+ shell: bash
147
+ run: |
148
+ cd hf-space
149
+
150
+ # Remove existing files except .git
151
+ find . -name '.git' -prune -o -type f -exec rm -f {} \;
152
+ find . -name '.git' -prune -o -type d -empty -exec rmdir {} \; 2>/dev/null || true
153
+
154
+ # Copy project files (excluding .git and other unnecessary files)
155
+ rsync -av --exclude='.git' --exclude='hf-space' --exclude='node_modules' --exclude='.next' ../ ./
156
+
157
+ # Copy the built .next directory if it exists
158
+ if [ -d "../.next" ]; then
159
+ cp -r ../.next ./
160
+ fi
161
+
162
+ - name: Configure git in Hugging Face Space
163
+ shell: bash
164
+ run: |
165
+ cd hf-space
166
+ git config user.name "GitHub Actions"
167
+ git config user.email "actions@github.com"
168
+
169
+ - name: Commit and push to Hugging Face Space
170
+ shell: bash
171
+ env:
172
+ ENVIRONMENT: ${{ inputs.environment }}
173
+ run: |
174
+ cd hf-space
175
+ git add .
176
+
177
+ # Check if there are changes to commit
178
+ if git diff --staged --quiet; then
179
+ echo "No changes to commit"
180
+ else
181
+ git commit -m "Deploy from GitHub Actions [${ENVIRONMENT}] - $(date '+%Y-%m-%d %H:%M:%S')"
182
+ git push origin main
183
+ fi
184
+
185
+ - name: Deployment status
186
+ shell: bash
187
+ env:
188
+ ENVIRONMENT: ${{ inputs.environment }}
189
+ HF_USERNAME: ${{ inputs.hf-username }}
190
+ HF_SPACE_NAME: ${{ inputs.hf-space-name }}
191
+ run: |
192
+ case "${ENVIRONMENT}" in
193
+ dev)
194
+ echo "🧪 Development deployment completed!"
195
+ ;;
196
+ test)
197
+ echo "🧪 Mock/Testing deployment completed!"
198
+ ;;
199
+ stg)
200
+ echo "🚧 Staging deployment completed!"
201
+ ;;
202
+ prod)
203
+ echo "🚀 Production deployment completed!"
204
+ ;;
205
+ esac
206
+ echo "Your app should be available at: https://huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}"
.github/workflows/deploy-dev.yml CHANGED
@@ -33,134 +33,11 @@ jobs:
33
  - name: Build application
34
  run: npm run build
35
 
36
- - name: Setup Python for Hugging Face CLI
37
- uses: actions/setup-python@v4
38
  with:
39
- python-version: '3.9'
40
-
41
- - name: Install Hugging Face Hub
42
- run: |
43
- pip install huggingface_hub
44
- sudo apt-get update && sudo apt-get install -y rsync
45
-
46
- - name: Validate secrets
47
- run: |
48
- echo "HF_USERNAME: ${{ env.HF_USERNAME }}"
49
- echo "HF_SPACE_NAME: ${{ env.HF_SPACE_NAME }}"
50
- echo "Token length: ${#HF_TOKEN}"
51
-
52
- - name: Create Hugging Face Space README
53
- run: |
54
- cat > README.md << 'EOF'
55
- ---
56
- title: ${{ env.HF_SPACE_NAME }}
57
- emoji: 🧪
58
- colorFrom: pink
59
- colorTo: yellow
60
- sdk: docker
61
- app_port: 7860
62
- pinned: false
63
- license: mit
64
- ---
65
-
66
- # ${{ env.HF_SPACE_NAME }} (Development)
67
-
68
- 🧪 **This is a development environment** - Features may be unstable
69
-
70
- This is a Next.js application deployed to Hugging Face Spaces from the `dev` branch.
71
-
72
- ## Features
73
-
74
- - Built with Next.js and React
75
- - Containerized with Docker
76
- - Automatic deployment from GitHub dev branch
77
- - Development environment for testing new features
78
-
79
- ## Development
80
-
81
- To run locally:
82
-
83
- ```bash
84
- npm install
85
- npm run dev
86
- ```
87
-
88
- The application will be available at http://localhost:3200
89
-
90
- ---
91
- **Branch**: dev
92
- **Environment**: Development
93
- **Last Deploy**: $(date)
94
- EOF
95
-
96
- - name: Clone or update Hugging Face Space
97
- run: |
98
- # Skip LFS for initial clone to avoid errors
99
- export GIT_LFS_SKIP_SMUDGE=1
100
-
101
- # Try to clone the space with authentication
102
- if git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space; then
103
- echo "✅ Space exists, updating..."
104
- cd hf-space
105
- # Reset any failed LFS state
106
- git lfs install --skip-smudge
107
- else
108
- echo "🆕 Creating new space..."
109
- # Create space using Python API (more reliable)
110
- python3 -c "
111
- from huggingface_hub import HfApi
112
- api = HfApi(token='${{ secrets.HF_TOKEN }}')
113
- try:
114
- api.create_repo(
115
- repo_id='${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}',
116
- repo_type='space',
117
- space_sdk='docker'
118
- )
119
- print('Space created successfully')
120
- except Exception as e:
121
- print(f'Space creation failed or already exists: {e}')
122
- "
123
- sleep 5
124
- git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space
125
- cd hf-space
126
- fi
127
-
128
- - name: Copy files to Hugging Face Space
129
- run: |
130
- cd hf-space
131
-
132
- # Remove existing files except .git
133
- find . -name '.git' -prune -o -type f -exec rm -f {} \;
134
- find . -name '.git' -prune -o -type d -empty -exec rmdir {} \; 2>/dev/null || true
135
-
136
- # Copy project files (excluding .git and other unnecessary files)
137
- rsync -av --exclude='.git' --exclude='hf-space' --exclude='node_modules' --exclude='.next' ../ ./
138
-
139
- # Copy the built .next directory if it exists
140
- if [ -d "../.next" ]; then
141
- cp -r ../.next ./
142
- fi
143
-
144
- - name: Configure git in Hugging Face Space
145
- run: |
146
- cd hf-space
147
- git config user.name "GitHub Actions"
148
- git config user.email "actions@github.com"
149
-
150
- - name: Commit and push to Hugging Face Space
151
- run: |
152
- cd hf-space
153
- git add .
154
-
155
- # Check if there are changes to commit
156
- if git diff --staged --quiet; then
157
- echo "No changes to commit"
158
- else
159
- git commit -m "Deploy from GitHub Actions [DEV] - $(date '+%Y-%m-%d %H:%M:%S')"
160
- git push origin main
161
- fi
162
-
163
- - name: Deployment status
164
- run: |
165
- echo "🧪 Development deployment completed!"
166
- echo "Your dev app should be available at: https://huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}"
 
33
  - name: Build application
34
  run: npm run build
35
 
36
+ - name: Deploy to Hugging Face Space
37
+ uses: ./.github/actions/deploy-to-hf
38
  with:
39
+ environment: dev
40
+ branch: ${{ github.ref_name }}
41
+ hf-username: ${{ env.HF_USERNAME }}
42
+ hf-token: ${{ env.HF_TOKEN }}
43
+ hf-space-name: ${{ env.HF_SPACE_NAME }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
.github/workflows/deploy-prod.yml CHANGED
@@ -32,125 +32,14 @@ jobs:
32
  - name: Build application
33
  run: npm run build
34
 
35
- - name: Setup Python for Hugging Face CLI
36
- uses: actions/setup-python@v5
37
  with:
38
- python-version: '3.9'
39
-
40
- - name: Install Hugging Face Hub
41
- run: |
42
- pip install huggingface_hub
43
- sudo apt-get update && sudo apt-get install -y rsync
44
-
45
- - name: Validate secrets
46
- run: |
47
- echo "HF_USERNAME: ${{ env.HF_USERNAME }}"
48
- echo "HF_SPACE_NAME: ${{ env.HF_SPACE_NAME }}"
49
- echo "Token length: ${#HF_TOKEN}"
50
-
51
- - name: Create Hugging Face Space README
52
- run: |
53
- cat > README.md << 'EOF'
54
- ---
55
- title: ${{ env.HF_SPACE_NAME }}
56
- emoji: 🚀
57
- colorFrom: pink
58
- colorTo: green
59
- sdk: docker
60
- app_port: 7860
61
- pinned: false
62
- license: mit
63
- ---
64
-
65
- # ${{ env.HF_SPACE_NAME }} (Production)
66
-
67
- ✅ **This is the production environment** - Stable and tested features
68
-
69
- This is a Next.js application deployed to Hugging Face Spaces from the `main` branch.
70
-
71
- ## Features
72
-
73
- - Built with Next.js and React
74
- - Containerized with Docker
75
- - Automatic deployment from GitHub main branch
76
- - Production-ready environment
77
-
78
- ## Development
79
-
80
- To run locally:
81
-
82
- ```bash
83
- npm install
84
- npm run dev
85
- ```
86
-
87
- The application will be available at http://localhost:3200
88
-
89
- ---
90
- **Branch**: main
91
- **Environment**: Production
92
- **Last Deploy**: $(date)
93
- EOF
94
-
95
- - name: Clone or update Hugging Face Space
96
- run: |
97
- # Skip LFS for initial clone to avoid errors
98
- export GIT_LFS_SKIP_SMUDGE=1
99
-
100
- # Try to clone the space with authentication
101
- if git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space; then
102
- echo "✅ Space exists, updating..."
103
- cd hf-space
104
- # Reset any failed LFS state
105
- git lfs install --skip-smudge
106
- else
107
- echo "🆕 Creating new space..."
108
- # Create space using Python API (more reliable)
109
- python3 -c 'from huggingface_hub import HfApi; api = HfApi(token="${{ secrets.HF_TOKEN }}"); api.create_repo(repo_id="${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}", repo_type="space", space_sdk="docker") if True else None' || echo "Space creation failed or already exists"
110
- sleep 5
111
- git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space
112
- cd hf-space
113
- fi
114
-
115
- - name: Copy files to Hugging Face Space
116
- run: |
117
- cd hf-space
118
-
119
- # Remove existing files except .git
120
- find . -name '.git' -prune -o -type f -exec rm -f {} \;
121
- find . -name '.git' -prune -o -type d -empty -exec rmdir {} \; 2>/dev/null || true
122
-
123
- # Copy project files (excluding .git and other unnecessary files)
124
- rsync -av --exclude='.git' --exclude='hf-space' --exclude='node_modules' --exclude='.next' ../ ./
125
-
126
- # Copy the built .next directory if it exists
127
- if [ -d "../.next" ]; then
128
- cp -r ../.next ./
129
- fi
130
-
131
- - name: Configure git in Hugging Face Space
132
- run: |
133
- cd hf-space
134
- git config user.name "GitHub Actions"
135
- git config user.email "actions@github.com"
136
-
137
- - name: Commit and push to Hugging Face Space
138
- run: |
139
- cd hf-space
140
- git add .
141
-
142
- # Check if there are changes to commit
143
- if git diff --staged --quiet; then
144
- echo "No changes to commit"
145
- else
146
- git commit -m "Deploy from GitHub Actions [PROD] - $(date '+%Y-%m-%d %H:%M:%S')"
147
- git push origin main
148
- fi
149
-
150
- - name: Deployment status
151
- run: |
152
- echo "🚀 Production deployment completed!"
153
- echo "Your production app should be available at: https://huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}"
154
 
155
  - name: Create Tag and Release
156
  uses: ./.github/actions/create-release
 
32
  - name: Build application
33
  run: npm run build
34
 
35
+ - name: Deploy to Hugging Face Space
36
+ uses: ./.github/actions/deploy-to-hf
37
  with:
38
+ environment: prod
39
+ branch: ${{ github.ref_name }}
40
+ hf-username: ${{ env.HF_USERNAME }}
41
+ hf-token: ${{ env.HF_TOKEN }}
42
+ hf-space-name: ${{ env.HF_SPACE_NAME }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
43
 
44
  - name: Create Tag and Release
45
  uses: ./.github/actions/create-release
.github/workflows/deploy-stg.yml CHANGED
@@ -33,125 +33,14 @@ jobs:
33
  - name: Build application
34
  run: npm run build
35
 
36
- - name: Setup Python for Hugging Face CLI
37
- uses: actions/setup-python@v5
38
  with:
39
- python-version: '3.9'
40
-
41
- - name: Install Hugging Face Hub
42
- run: |
43
- pip install huggingface_hub
44
- sudo apt-get update && sudo apt-get install -y rsync
45
-
46
- - name: Validate secrets
47
- run: |
48
- echo "HF_USERNAME: ${{ env.HF_USERNAME }}"
49
- echo "HF_SPACE_NAME: ${{ env.HF_SPACE_NAME }}"
50
- echo "Token length: ${#HF_TOKEN}"
51
-
52
- - name: Create Hugging Face Space README
53
- run: |
54
- cat > README.md << 'EOF'
55
- ---
56
- title: ${{ env.HF_SPACE_NAME }}
57
- emoji: 🧪
58
- colorFrom: pink
59
- colorTo: indigo
60
- sdk: docker
61
- app_port: 7860
62
- pinned: false
63
- license: mit
64
- ---
65
-
66
- # ${{ env.HF_SPACE_NAME }} (Development)
67
-
68
- 🧪 **This is a development environment** - Features may be unstable
69
-
70
- This is a Next.js application deployed to Hugging Face Spaces from the `dev` branch.
71
-
72
- ## Features
73
-
74
- - Built with Next.js and React
75
- - Containerized with Docker
76
- - Automatic deployment from GitHub dev branch
77
- - Development environment for testing new features
78
-
79
- ## Development
80
-
81
- To run locally:
82
-
83
- ```bash
84
- npm install
85
- npm run dev
86
- ```
87
-
88
- The application will be available at http://localhost:3200
89
-
90
- ---
91
- **Branch**: dev
92
- **Environment**: Development
93
- **Last Deploy**: $(date)
94
- EOF
95
-
96
- - name: Clone or update Hugging Face Space
97
- run: |
98
- # Skip LFS for initial clone to avoid errors
99
- export GIT_LFS_SKIP_SMUDGE=1
100
-
101
- # Try to clone the space with authentication
102
- if git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space; then
103
- echo "✅ Space exists, updating..."
104
- cd hf-space
105
- # Reset any failed LFS state
106
- git lfs install --skip-smudge
107
- else
108
- echo "🆕 Creating new space..."
109
- # Create space using Python API (more reliable)
110
- python3 -c 'from huggingface_hub import HfApi; api = HfApi(token="${{ secrets.HF_TOKEN }}"); api.create_repo(repo_id="${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}", repo_type="space", space_sdk="docker") if True else None' || echo "Space creation failed or already exists"
111
- sleep 5
112
- git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space
113
- cd hf-space
114
- fi
115
-
116
- - name: Copy files to Hugging Face Space
117
- run: |
118
- cd hf-space
119
-
120
- # Remove existing files except .git
121
- find . -name '.git' -prune -o -type f -exec rm -f {} \;
122
- find . -name '.git' -prune -o -type d -empty -exec rmdir {} \; 2>/dev/null || true
123
-
124
- # Copy project files (excluding .git and other unnecessary files)
125
- rsync -av --exclude='.git' --exclude='hf-space' --exclude='node_modules' --exclude='.next' ../ ./
126
-
127
- # Copy the built .next directory if it exists
128
- if [ -d "../.next" ]; then
129
- cp -r ../.next ./
130
- fi
131
-
132
- - name: Configure git in Hugging Face Space
133
- run: |
134
- cd hf-space
135
- git config user.name "GitHub Actions"
136
- git config user.email "actions@github.com"
137
-
138
- - name: Commit and push to Hugging Face Space
139
- run: |
140
- cd hf-space
141
- git add .
142
-
143
- # Check if there are changes to commit
144
- if git diff --staged --quiet; then
145
- echo "No changes to commit"
146
- else
147
- git commit -m "Deploy from GitHub Actions [DEV] - $(date '+%Y-%m-%d %H:%M:%S')"
148
- git push origin main
149
- fi
150
-
151
- - name: Deployment status
152
- run: |
153
- echo "🧪 Development deployment completed!"
154
- echo "Your dev app should be available at: https://huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}"
155
 
156
  - name: Create Tag and Pre-release
157
  uses: ./.github/actions/create-release
 
33
  - name: Build application
34
  run: npm run build
35
 
36
+ - name: Deploy to Hugging Face Space
37
+ uses: ./.github/actions/deploy-to-hf
38
  with:
39
+ environment: stg
40
+ branch: ${{ github.ref_name }}
41
+ hf-username: ${{ env.HF_USERNAME }}
42
+ hf-token: ${{ env.HF_TOKEN }}
43
+ hf-space-name: ${{ env.HF_SPACE_NAME }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  - name: Create Tag and Pre-release
46
  uses: ./.github/actions/create-release
.github/workflows/deploy-test.yml CHANGED
@@ -32,138 +32,11 @@ jobs:
32
  - name: Build application
33
  run: npm run build
34
 
35
- - name: Setup Python for Hugging Face CLI
36
- uses: actions/setup-python@v4
37
  with:
38
- python-version: '3.9'
39
-
40
- - name: Install Hugging Face Hub
41
- run: |
42
- pip install huggingface_hub
43
- sudo apt-get update && sudo apt-get install -y rsync
44
-
45
- - name: Validate secrets
46
- run: |
47
- echo "HF_USERNAME: ${{ env.HF_USERNAME }}"
48
- echo "HF_SPACE_NAME: ${{ env.HF_SPACE_NAME }}"
49
- echo "Token length: ${#HF_TOKEN}"
50
-
51
- - name: Create Hugging Face Space README
52
- run: |
53
- cat > README.md << 'EOF'
54
- ---
55
- title: ${{ env.HF_SPACE_NAME }}
56
- emoji: 🧪
57
- colorFrom: pink
58
- colorTo: gray
59
- sdk: docker
60
- app_port: 7860
61
- pinned: false
62
- license: mit
63
- ---
64
-
65
- # ${{ env.HF_SPACE_NAME }} (Mock/Testing)
66
-
67
- 🧪 **This is the mock/testing environment** - Feature branch deployment
68
-
69
- This is a Next.js application deployed to Hugging Face Spaces from the `feature/html-preview` branch.
70
-
71
- ## Features
72
-
73
- - Built with Next.js and React
74
- - Containerized with Docker
75
- - Automatic deployment from GitHub feature/html-preview branch
76
- - Mock/testing environment
77
-
78
- ## Development
79
-
80
- To run locally:
81
-
82
- ```bash
83
- npm install
84
- npm run dev
85
- ```
86
-
87
- The application will be available at http://localhost:3200
88
-
89
- ---
90
- **Branch**: feature/html-preview
91
- **Environment**: Mock/Testing
92
- **Last Deploy**: $(date)
93
- EOF
94
-
95
- - name: Clone or update Hugging Face Space
96
- run: |
97
- # Skip LFS for initial clone to avoid errors
98
- export GIT_LFS_SKIP_SMUDGE=1
99
-
100
- # Try to clone the space with authentication
101
- if git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space; then
102
- echo "✅ Space exists, updating..."
103
- cd hf-space
104
- # Reset any failed LFS state
105
- git lfs install --skip-smudge
106
- else
107
- echo "🆕 Creating new space..."
108
- # Create space using Python API (more reliable)
109
- python3 -c "
110
- from huggingface_hub import HfApi
111
- api = HfApi(token='${{ secrets.HF_TOKEN }}')
112
- try:
113
- api.create_repo(
114
- repo_id='${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}',
115
- repo_type='space',
116
- space_sdk='docker'
117
- )
118
- print('Space created successfully')
119
- except Exception as e:
120
- print(f'Space creation failed or already exists: {e}')
121
- "
122
- sleep 5
123
- git clone https://user:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }} hf-space
124
- cd hf-space
125
- fi
126
-
127
- - name: Copy files to Hugging Face Space
128
- run: |
129
- cd hf-space
130
-
131
- # Remove existing files except .git
132
- find . -name '.git' -prune -o -type f -exec rm -f {} \;
133
- find . -name '.git' -prune -o -type d -empty -exec rmdir {} \; 2>/dev/null || true
134
-
135
- # Copy project files (excluding .git and other unnecessary files)
136
- rsync -av --exclude='.git' --exclude='hf-space' --exclude='node_modules' --exclude='.next' ../ ./
137
-
138
- # Copy the built .next directory if it exists
139
- if [ -d "../.next" ]; then
140
- cp -r ../.next ./
141
- fi
142
-
143
- - name: Configure git in Hugging Face Space
144
- run: |
145
- cd hf-space
146
- git config user.name "GitHub Actions"
147
- git config user.email "actions@github.com"
148
-
149
- # Allow incomplete LFS push if needed
150
- git config lfs.allowincompletepush true
151
-
152
- - name: Commit and push to Hugging Face Space
153
- run: |
154
- cd hf-space
155
- git add .
156
-
157
- # Check if there are changes to commit
158
- if git diff --staged --quiet; then
159
- echo "No changes to commit"
160
- else
161
- git commit -m "Deploy from GitHub Actions [MOCK] - $(date '+%Y-%m-%d %H:%M:%S')"
162
- git push origin main --force
163
- fi
164
-
165
- - name: Deployment status
166
- run: |
167
- echo "🧪 Mock/Testing deployment completed!"
168
- echo "Your mock app should be available at: https://huggingface.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}"
169
- echo "Deployed at: $(date '+%Y-%m-%d %H:%M:%S')"
 
32
  - name: Build application
33
  run: npm run build
34
 
35
+ - name: Deploy to Hugging Face Space
36
+ uses: ./.github/actions/deploy-to-hf
37
  with:
38
+ environment: test
39
+ branch: ${{ github.ref_name }}
40
+ hf-username: ${{ env.HF_USERNAME }}
41
+ hf-token: ${{ env.HF_TOKEN }}
42
+ hf-space-name: ${{ env.HF_SPACE_NAME }}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -9,18 +9,18 @@ pinned: false
9
  license: mit
10
  ---
11
 
12
- # FE_Stage (Development)
13
 
14
- 🧪 **This is a development environment** - Features may be unstable
15
 
16
- This is a Next.js application deployed to Hugging Face Spaces from the `dev` branch.
17
 
18
  ## Features
19
 
20
  - Built with Next.js and React
21
  - Containerized with Docker
22
- - Automatic deployment from GitHub dev branch
23
- - Development environment for testing new features
24
 
25
  ## Development
26
 
@@ -34,6 +34,6 @@ npm run dev
34
  The application will be available at http://localhost:3200
35
 
36
  ---
37
- **Branch**: dev
38
- **Environment**: Development
39
- **Last Deploy**: $(date)
 
9
  license: mit
10
  ---
11
 
12
+ # FE_Stage (Staging)
13
 
14
+ 🚧 **This is a staging environment** - Pre-production testing
15
 
16
+ This is a Next.js application deployed to Hugging Face Spaces from the `stg` branch.
17
 
18
  ## Features
19
 
20
  - Built with Next.js and React
21
  - Containerized with Docker
22
+ - Automatic deployment from GitHub stg branch
23
+ - Staging environment
24
 
25
  ## Development
26
 
 
34
  The application will be available at http://localhost:3200
35
 
36
  ---
37
+ **Branch**: stg
38
+ **Environment**: Staging
39
+ **Last Deploy**: Fri Oct 31 07:09:57 UTC 2025