File tree Expand file tree Collapse file tree 2 files changed +83
-1
lines changed
Expand file tree Collapse file tree 2 files changed +83
-1
lines changed Original file line number Diff line number Diff line change 1+ name : Deploy HF Space
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ repo_id :
7+ description : " Hugging Face repo id (username/space-name). Leave blank to use repo variable HF_SPACE_REPO_ID."
8+ required : false
9+ type : string
10+ private :
11+ description : " Create or update the target Space as private"
12+ required : false
13+ default : false
14+ type : boolean
15+ create_pr :
16+ description : " Upload via Pull Request instead of direct push"
17+ required : false
18+ default : false
19+ type : boolean
20+
21+ jobs :
22+ deploy :
23+ runs-on : ubuntu-latest
24+ timeout-minutes : 30
25+ env :
26+ HF_TOKEN : ${{ secrets.HF_TOKEN }}
27+ HF_SPACE_REPO_ID : ${{ inputs.repo_id || vars.HF_SPACE_REPO_ID }}
28+
29+ steps :
30+ - uses : actions/checkout@v6.0.2
31+
32+ - uses : actions/setup-python@v6.2.0
33+ with :
34+ python-version : " 3.11"
35+
36+ - name : Install uv
37+ uses : astral-sh/setup-uv@v8.0.0
38+
39+ - name : Check deployment configuration
40+ run : |
41+ if [ -z "${HF_TOKEN}" ]; then
42+ echo "::error::Missing repository secret HF_TOKEN"
43+ exit 1
44+ fi
45+ if [ -z "${HF_SPACE_REPO_ID}" ]; then
46+ echo "::error::Missing workflow input repo_id and repository variable HF_SPACE_REPO_ID"
47+ exit 1
48+ fi
49+ echo "Deploying to ${HF_SPACE_REPO_ID}"
50+
51+ - name : Validate local environment structure
52+ run : uvx --from git+https://github.com/meta-pytorch/OpenEnv.git openenv validate --verbose
53+
54+ - name : Push to Hugging Face Space
55+ run : |
56+ args=(. --repo-id "${HF_SPACE_REPO_ID}")
57+ if [ "${{ inputs.private }}" = "true" ]; then
58+ args+=(--private)
59+ fi
60+ if [ "${{ inputs.create_pr }}" = "true" ]; then
61+ args+=(--create-pr)
62+ fi
63+ uvx --from git+https://github.com/meta-pytorch/OpenEnv.git openenv push "${args[@]}"
Original file line number Diff line number Diff line change @@ -98,6 +98,26 @@ openenv validate --verbose
9898openenv validate http://127.0.0.1:8000
9999```
100100
101+ ## GitHub-only deployment to Hugging Face Spaces
102+
103+ This repo is set up so deployment can be triggered from GitHub Actions instead of
104+ from a local machine.
105+
106+ Add these repository settings in GitHub:
107+
108+ - Secret: ` HF_TOKEN `
109+ - Variable: ` HF_SPACE_REPO_ID `
110+ Example: ` your-hf-username/openenv-code-review-arena `
111+
112+ Then run the ` Deploy HF Space ` workflow from the GitHub Actions tab.
113+ The workflow will:
114+
115+ 1 . validate the environment again
116+ 2 . create the Space if it does not exist
117+ 3 . push the current repository contents with ` openenv push `
118+
119+ You can also override the target repo id manually when dispatching the workflow.
120+
101121## Example usage
102122
103123``` python
@@ -159,4 +179,3 @@ openenv push --repo-id <your-hf-space>
159179No API keys are required for the benchmark itself. If you later want a private rubric
160180bundle for leaderboard use, you can point ` CODE_REVIEW_TASK_BUNDLE_PATH ` at a private
161181JSON file without changing the environment interface.
162-
You can’t perform that action at this time.
0 commit comments