Spaces:
Build error
Build error
Abhinav Gavireddi
commited on
Commit
·
481c367
1
Parent(s):
b3e9681
fix: fixed issue with pushing codes to HF
Browse files- .github/workflows/ci.yaml +30 -17
.github/workflows/ci.yaml
CHANGED
@@ -25,30 +25,43 @@ jobs:
|
|
25 |
# if [ -f tests/test.py ]; then python -m unittest discover -s tests; fi
|
26 |
|
27 |
deploy-to-hf:
|
28 |
-
needs: build-and-test
|
29 |
runs-on: ubuntu-latest
|
30 |
-
if: github.ref == 'refs/heads/main'
|
31 |
environment: prod
|
32 |
steps:
|
33 |
-
- name: Checkout
|
34 |
uses: actions/checkout@v3
|
35 |
with:
|
36 |
-
fetch-depth: 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
|
38 |
-
- name:
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
|
41 |
-
|
42 |
-
|
43 |
|
44 |
-
|
45 |
-
|
46 |
|
47 |
-
|
48 |
-
|
49 |
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
|
|
25 |
# if [ -f tests/test.py ]; then python -m unittest discover -s tests; fi
|
26 |
|
27 |
deploy-to-hf:
|
|
|
28 |
runs-on: ubuntu-latest
|
|
|
29 |
environment: prod
|
30 |
steps:
|
31 |
+
- name: Checkout code
|
32 |
uses: actions/checkout@v3
|
33 |
with:
|
34 |
+
fetch-depth: 0 # Full git history if needed for versioning or changelog
|
35 |
+
|
36 |
+
- name: Set up Python
|
37 |
+
uses: actions/setup-python@v4
|
38 |
+
with:
|
39 |
+
python-version: '3.10' # Use whatever version you prefer
|
40 |
+
|
41 |
+
- name: Install Hugging Face Hub client
|
42 |
+
run: pip install huggingface_hub
|
43 |
|
44 |
+
- name: Push to Hugging Face Space
|
45 |
+
env:
|
46 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
47 |
+
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
48 |
+
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
|
49 |
+
run: |
|
50 |
+
echo "Pushing latest code to Hugging Face Space"
|
51 |
+
git config --global user.email "[email protected]"
|
52 |
+
git config --global user.name "Abhinav_Gavireddi"
|
53 |
|
54 |
+
# Set up Hugging Face CLI
|
55 |
+
huggingface-cli login --token "$HF_TOKEN"
|
56 |
|
57 |
+
# Add Hugging Face as remote
|
58 |
+
git remote add hf https://huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}
|
59 |
|
60 |
+
# Push code to the Space repo
|
61 |
+
git push hf main
|
62 |
|
63 |
+
# Optional: Restart Space via API (defensive move)
|
64 |
+
python -c "
|
65 |
+
from huggingface_hub import HfApi;
|
66 |
+
api = HfApi(token='$HF_TOKEN');
|
67 |
+
api.restart_space(repo_id='${HF_USERNAME}/${HF_SPACE_NAME}')
|