S-Dreamer commited on
Commit
eee93b5
·
verified ·
1 Parent(s): 6b1018a

Create .github/workflows/deploy.yml

Browse files
Files changed (1) hide show
  1. .github/workflows/deploy.yml +57 -0
.github/workflows/deploy.yml ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Build and Deploy Chat Demo
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ build:
13
+ name: Lint, Test, and Validate
14
+ runs-on: ubuntu-latest
15
+
16
+ steps:
17
+ - name: Checkout Repository
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: '3.11'
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install -r requirements.txt
29
+
30
+ - name: Lint and Style Check
31
+ run: |
32
+ pip install flake8 pylint
33
+ flake8 . --max-line-length=100 --statistics
34
+ pylint $(git ls-files '*.py') --score=n || true
35
+
36
+ - name: Smoke Test
37
+ run: |
38
+ python - <<'PYCODE'
39
+ import importlib.util
40
+ spec = importlib.util.spec_from_file_location("app", "app.py")
41
+ if spec is None:
42
+ raise SystemExit("app.py not found")
43
+ print("✅ Import test OK")
44
+ PYCODE
45
+
46
+ deploy:
47
+ if: github.ref == 'refs/heads/main'
48
+ needs: build
49
+ runs-on: ubuntu-latest
50
+ steps:
51
+ - name: Trigger Hugging Face Space rebuild
52
+ env:
53
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
54
+ run: |
55
+ curl -X POST \
56
+ -H "Authorization: Bearer $HF_TOKEN" \
57
+ https://huggingface.co/api/spaces/YOUR_USERNAME/YOUR_SPACE_ID/restart