Skip to content

Commit eb818c1

Browse files
thompsonsonclaude
andcommitted
feat: improve HF deployment workflow with proper configuration
- 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 <[email protected]>
1 parent 706af58 commit eb818c1

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
name: Deploy to Hugging Face Spaces
22

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+
39
on:
410
workflow_run:
511
workflows: ["CI"]
@@ -8,6 +14,10 @@ on:
814
branches: [ main ]
915
workflow_dispatch:
1016

17+
env:
18+
HF_USERNAME: "thompsonson"
19+
HF_SPACE_NAME: "bayesian_game"
20+
1121
jobs:
1222
deploy:
1323
runs-on: ubuntu-latest
@@ -23,7 +33,11 @@ jobs:
2333
env:
2434
HF_TOKEN: ${{ secrets.HF_TOKEN }}
2535
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
2640
git config --global user.email "[email protected]"
2741
git config --global user.name "GitHub Action"
28-
git remote add hf https://thompsonson:[email protected]/spaces/thompsonson/bayesian_game
42+
git remote add hf https://${{ env.HF_USERNAME }}:[email protected]/spaces/${{ env.HF_USERNAME }}/${{ env.HF_SPACE_NAME }}
2943
git push hf main --force

README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,24 @@ Round 3: Evidence "same" (dice roll = target)
275275

276276
## 🚀 Deployment
277277

278-
Ready for deployment on:
279-
- **Hugging Face Spaces**: Direct deployment support
280-
- **Local Server**: Built-in Gradio server
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`)
281296
- **Cloud Platforms**: Standard Python web app deployment
282297

283298
---

0 commit comments

Comments
 (0)