-
Notifications
You must be signed in to change notification settings - Fork 0
83 lines (73 loc) · 2.59 KB
/
deploy-space.yml
File metadata and controls
83 lines (73 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
name: Deploy HF Space
on:
push:
branches: ["main"]
workflow_dispatch:
inputs:
repo_id:
description: "Hugging Face repo id (username/space-name). Leave blank to use repo variable HF_SPACE_REPO_ID."
required: false
type: string
private:
description: "Create or update the target Space as private"
required: false
default: false
type: boolean
create_pr:
description: "Upload via Pull Request instead of direct push"
required: false
default: false
type: boolean
jobs:
deploy:
runs-on: ubuntu-latest
timeout-minutes: 30
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
HF_SPACE_REPO_ID: ${{ inputs.repo_id || vars.HF_SPACE_REPO_ID || 'Rohan556/openenv-code-review-arena' }}
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-python@v6.2.0
with:
python-version: "3.11"
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
- name: Check deployment configuration
id: config
run: |
if [ -z "${HF_TOKEN}" ]; then
echo "deploy_enabled=false" >> "$GITHUB_OUTPUT"
echo "HF_TOKEN is not configured; skipping deploy."
exit 0
fi
if [ -z "${HF_SPACE_REPO_ID}" ]; then
echo "::error::Missing workflow input repo_id and repository variable HF_SPACE_REPO_ID"
exit 1
fi
echo "deploy_enabled=true" >> "$GITHUB_OUTPUT"
echo "Deploying to ${HF_SPACE_REPO_ID}"
- name: Validate local environment structure
if: steps.config.outputs.deploy_enabled == 'true'
run: uvx --from git+https://github.com/meta-pytorch/OpenEnv.git openenv validate --verbose
- name: Push to Hugging Face Space
if: steps.config.outputs.deploy_enabled == 'true'
run: |
args=(. --repo-id "${HF_SPACE_REPO_ID}")
if [ "${{ inputs.private }}" = "true" ]; then
args+=(--private)
fi
if [ "${{ inputs.create_pr }}" = "true" ]; then
args+=(--create-pr)
fi
for attempt in 1 2 3; do
echo "Hugging Face push attempt ${attempt}/3"
if uvx --from git+https://github.com/meta-pytorch/OpenEnv.git openenv push "${args[@]}"; then
exit 0
fi
if [ "${attempt}" -lt 3 ]; then
echo "Push failed, retrying after backoff..."
sleep $((attempt * 20))
fi
done
echo "::error::Failed to push to Hugging Face Space after 3 attempts"
exit 1