Spaces:
Running
Running
ci: improve HF Space sync workflow with git-based approach
Browse files
.github/workflows/sync-to-hf-space.yml
CHANGED
|
@@ -13,8 +13,16 @@ jobs:
|
|
| 13 |
fetch-depth: 0
|
| 14 |
|
| 15 |
- name: Push to Hugging Face Space
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
fetch-depth: 0
|
| 14 |
|
| 15 |
- name: Push to Hugging Face Space
|
| 16 |
+
env:
|
| 17 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 18 |
+
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 19 |
+
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
|
| 20 |
+
run: |
|
| 21 |
+
git clone https://oauth2:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} /tmp/hf-space
|
| 22 |
+
cp -r . /tmp/hf-space/ --exclude='.git' --exclude='.github' --exclude='__pycache__' --exclude='.pytest_cache' --exclude='.ruff_cache'
|
| 23 |
+
cd /tmp/hf-space
|
| 24 |
+
git config user.email "action@github.com"
|
| 25 |
+
git config user.name "GitHub Action"
|
| 26 |
+
git add -A
|
| 27 |
+
git diff --staged --quiet || git commit -m "Sync from GitHub"
|
| 28 |
+
git push
|