vinith17 commited on
Commit
96775ab
Β·
1 Parent(s): 273e960

ci: sync GitHub to Hugging Face Space via hub-sync + server/app shim

Browse files

- Add GitHub Action (huggingface/hub-sync) on push to main, docker Space, target vinith17/CodeBug
- Add server/app.py with main() and app re-export for OpenEnv-style layouts
- Requires HF_TOKEN secret in GitHub Actions for sync to succeed

Made-with: Cursor

.github/workflows/sync-huggingface-space.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Mirrors this GitHub repo to your Hugging Face Space on every push to main.
2
+ #
3
+ # Setup (one-time):
4
+ # 1. GitHub β†’ Settings β†’ Secrets and variables β†’ Actions β†’ New secret: HF_TOKEN
5
+ # (Hugging Face token with write access to the Space β€” create at huggingface.co/settings/tokens)
6
+ # 2. If your Space is not "vinith17/CodeBug", edit huggingface_repo_id in this file.
7
+ #
8
+ # If the Space is also "Connected to GitHub" in HF Settings, pick ONE sync method to avoid conflicts
9
+ # (either disconnect native GitHub on HF and rely on this Action, or fix the native integration and
10
+ # delete this workflow).
11
+ #
12
+ # Docs: https://huggingface.co/docs/hub/main/spaces-github-actions
13
+
14
+ name: Sync to Hugging Face Space
15
+
16
+ on:
17
+ push:
18
+ branches: [main]
19
+ workflow_dispatch:
20
+
21
+ jobs:
22
+ sync:
23
+ runs-on: ubuntu-latest
24
+ steps:
25
+ - uses: actions/checkout@v4
26
+
27
+ - name: Sync GitHub β†’ Hugging Face Space
28
+ uses: huggingface/hub-sync@v0.1.0
29
+ with:
30
+ github_repo_id: ${{ github.repository }}
31
+ # Must match your Space: https://huggingface.co/spaces/<user>/<name>
32
+ huggingface_repo_id: vinith17/CodeBug
33
+ hf_token: ${{ secrets.HF_TOKEN }}
34
+ repo_type: space
35
+ space_sdk: docker
server/__init__.py CHANGED
@@ -1 +1 @@
1
- # server package
 
1
+ # Server package for OpenEnv-style layouts (server/app.py).
server/app.py CHANGED
@@ -1,11 +1,25 @@
1
- """server/app.py β€” OpenEnv multi-mode entry point."""
2
- import uvicorn
3
- from main import app
4
 
 
 
5
 
6
- def main():
7
- """Start the CodeBug server."""
8
- uvicorn.run(app, host="0.0.0.0", port=7860)
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
 
11
  if __name__ == "__main__":
 
1
+ """
2
+ OpenEnv / HF layout shim: some tooling expects server/app.py with app + main().
 
3
 
4
+ The real FastAPI app lives at repo root (main.py). CMD uses: uvicorn main:app
5
+ """
6
 
7
+ from __future__ import annotations
8
+
9
+ import os
10
+ import sys
11
+
12
+ _ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
13
+ if _ROOT not in sys.path:
14
+ sys.path.insert(0, _ROOT)
15
+
16
+ from main import app as app # noqa: E402
17
+
18
+
19
+ def main(host: str = "0.0.0.0", port: int = 7860) -> None:
20
+ import uvicorn
21
+
22
+ uvicorn.run("server.app:app", host=host, port=port, factory=False)
23
 
24
 
25
  if __name__ == "__main__":