thompsonson Claude commited on
Commit
eb818c1
·
1 Parent(s): 706af58

feat: improve HF deployment workflow with proper configuration

Browse files

- Add configurable environment variables for HF username and space name
- Include comprehensive setup instructions in workflow comments
- Add error checking for missing HF_TOKEN secret
- Update README with step-by-step deployment setup guide
- Make deployment workflow generic and reusable

🤖 Generated with [Claude Code](https://claude.ai/code)

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

Files changed (2) hide show
  1. .github/workflows/deploy.yml +15 -1
  2. README.md +18 -3
.github/workflows/deploy.yml CHANGED
@@ -1,5 +1,11 @@
1
  name: Deploy to Hugging Face Spaces
2
 
 
 
 
 
 
 
3
  on:
4
  workflow_run:
5
  workflows: ["CI"]
@@ -8,6 +14,10 @@ on:
8
  branches: [ main ]
9
  workflow_dispatch:
10
 
 
 
 
 
11
  jobs:
12
  deploy:
13
  runs-on: ubuntu-latest
@@ -23,7 +33,11 @@ jobs:
23
  env:
24
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
25
  run: |
 
 
 
 
26
  git config --global user.email "action@github.com"
27
  git config --global user.name "GitHub Action"
28
- git remote add hf https://thompsonson:$HF_TOKEN@hf.co/spaces/thompsonson/bayesian_game
29
  git push hf main --force
 
1
  name: Deploy to Hugging Face Spaces
2
 
3
+ # To enable this workflow:
4
+ # 1. Create a Hugging Face account and create a Space at https://hf.co/new-space
5
+ # 2. Get your HF token from https://hf.co/settings/tokens (with write access)
6
+ # 3. Add HF_TOKEN as a repository secret in GitHub Settings > Secrets and variables > Actions
7
+ # 4. Update the environment variables below with your HF username and space name
8
+
9
  on:
10
  workflow_run:
11
  workflows: ["CI"]
 
14
  branches: [ main ]
15
  workflow_dispatch:
16
 
17
+ env:
18
+ HF_USERNAME: "thompsonson"
19
+ HF_SPACE_NAME: "bayesian_game"
20
+
21
  jobs:
22
  deploy:
23
  runs-on: ubuntu-latest
 
33
  env:
34
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
35
  run: |
36
+ if [ -z "$HF_TOKEN" ]; then
37
+ echo "Error: HF_TOKEN secret not set. Please add your Hugging Face token to repository secrets."
38
+ exit 1
39
+ fi
40
  git config --global user.email "action@github.com"
41
  git config --global user.name "GitHub Action"
42
+ git remote add hf https://${{ env.HF_USERNAME }}:$HF_TOKEN@hf.co/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}
43
  git push hf main --force
README.md CHANGED
@@ -275,9 +275,24 @@ Round 3: Evidence "same" (dice roll = target)
275
 
276
  ## 🚀 Deployment
277
 
278
- Ready for deployment on:
279
- - **Hugging Face Spaces**: Direct deployment support
280
- - **Local Server**: Built-in Gradio server
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
281
  - **Cloud Platforms**: Standard Python web app deployment
282
 
283
  ---
 
275
 
276
  ## 🚀 Deployment
277
 
278
+ ### Hugging Face Spaces (Automated)
279
+
280
+ The repository includes automated deployment to Hugging Face Spaces via GitHub Actions. To set this up:
281
+
282
+ 1. **Create a Hugging Face Space**: Go to [hf.co/new-space](https://hf.co/new-space) and create a new Gradio space
283
+ 2. **Get your HF Token**: Visit [hf.co/settings/tokens](https://hf.co/settings/tokens) and create a token with write access
284
+ 3. **Add GitHub Secret**: In your GitHub repository, go to Settings > Secrets and variables > Actions, and add:
285
+ - Name: `HF_TOKEN`
286
+ - Value: Your Hugging Face token
287
+ 4. **Update workflow**: Edit `.github/workflows/deploy.yml` and replace:
288
+ - `HF_USERNAME`: Your Hugging Face username
289
+ - `HF_SPACE_NAME`: Your space name
290
+
291
+ The deployment will automatically trigger after successful CI runs on the main branch.
292
+
293
+ ### Other Deployment Options
294
+
295
+ - **Local Server**: Built-in Gradio server (`python app.py`)
296
  - **Cloud Platforms**: Standard Python web app deployment
297
 
298
  ---