julius119 commited on
Commit
4ef98e2
·
verified ·
1 Parent(s): 7fc45a6

Upload .github/workflows/ci-cd-hf.yaml

Browse files
Files changed (1) hide show
  1. .github/workflows/ci-cd-hf.yaml +77 -0
.github/workflows/ci-cd-hf.yaml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # VerseFlow Studio v5.0 CI/CD Workflow (improved)
2
+ # Author: XiaoZhe (WeChat: julius119 | Email: janejulius119@gmail.com)
3
+
4
+ name: VerseFlow Studio CI & HF Sync
5
+
6
+ on:
7
+ push:
8
+ branches: [ main ]
9
+ tags: [ 'v*' ]
10
+
11
+ concurrency:
12
+ group: ci-cd-hf-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
15
+ permissions:
16
+ contents: read
17
+
18
+ jobs:
19
+ build-and-deploy:
20
+ runs-on: ubuntu-latest
21
+ if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
22
+ env:
23
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
24
+ HF_REPO: xiaozhe/verseflow-studio-v5
25
+ steps:
26
+ - name: Checkout
27
+ uses: actions/checkout@v4
28
+ with:
29
+ fetch-depth: 0
30
+
31
+ - name: Set up Python 3.11
32
+ uses: actions/setup-python@v5
33
+ with:
34
+ python-version: '3.11'
35
+
36
+ - name: Cache pip
37
+ uses: actions/cache@v4
38
+ with:
39
+ path: ~/.cache/pip
40
+ key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
41
+ restore-keys: |
42
+ ${{ runner.os }}-pip-
43
+
44
+ - name: Install dependencies
45
+ run: |
46
+ python -m pip install --upgrade pip
47
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
48
+ pip install 'huggingface_hub>=0.18.0'
49
+
50
+ - name: Run tests / linters (optional)
51
+ run: |
52
+ echo "Run tests or linters here (optional)"
53
+
54
+ - name: Deploy to Hugging Face Hub
55
+ env:
56
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
57
+ HF_REPO: ${{ env.HF_REPO }}
58
+ run: |
59
+ python - <<'PY'
60
+ import os, sys
61
+ from huggingface_hub import HfApi
62
+
63
+ token = os.environ.get("HF_TOKEN")
64
+ if not token:
65
+ print("HF_TOKEN not set", file=sys.stderr)
66
+ sys.exit(1)
67
+
68
+ api = HfApi(token=token)
69
+ repo_id = os.environ.get("HF_REPO", "xiaozhe/verseflow-studio-v5")
70
+ api.create_repo(repo_id=repo_id, repo_type="model", exist_ok=True)
71
+
72
+ # Only upload relevant artifacts; exclude CI configs, local envs, and tests
73
+ ignore_patterns = ['.git*', '.github/*', '.venv*', 'tests/*', '__pycache__', '*.pyc']
74
+ api.upload_folder(folder_path='.', repo_id=repo_id, repo_type='model', ignore_patterns=ignore_patterns)
75
+
76
+ print("Successfully synced to Hugging Face Hub")
77
+ PY