Spaces:
Running
Running
Deminiko
commited on
Commit
·
2d758b7
1
Parent(s):
25e624c
workflow1
Browse files- .github/workflows/sync-to-hf.yml +80 -0
- .hf-config +10 -0
.github/workflows/sync-to-hf.yml
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Sync to Hugging Face hub
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
branches: [main]
|
| 6 |
+
workflow_dispatch:
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
sync-to-hub:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
steps:
|
| 12 |
+
- name: Checkout repository
|
| 13 |
+
uses: actions/checkout@v3
|
| 14 |
+
with:
|
| 15 |
+
fetch-depth: 0
|
| 16 |
+
lfs: true
|
| 17 |
+
|
| 18 |
+
- name: Check for large files (>10MB)
|
| 19 |
+
run: |
|
| 20 |
+
echo "Checking for files > 10MB in repository..."
|
| 21 |
+
git ls-tree -r -l --full-tree HEAD | awk '$4 >= 10485760 {print $0}' > /tmp/largefiles || true
|
| 22 |
+
if [ -s /tmp/largefiles ]; then
|
| 23 |
+
echo "ERROR: Found files larger than 10MB. List:"
|
| 24 |
+
cat /tmp/largefiles
|
| 25 |
+
exit 1
|
| 26 |
+
fi
|
| 27 |
+
|
| 28 |
+
- name: Sanity: ensure HF config exists, install deps, quick smoke tests
|
| 29 |
+
run: |
|
| 30 |
+
if [ ! -f .hf-config ]; then
|
| 31 |
+
echo "ERROR: .hf-config not found. Create .hf-config with HF_USERNAME and HF_SPACE_NAME"
|
| 32 |
+
exit 1
|
| 33 |
+
fi
|
| 34 |
+
|
| 35 |
+
# Install runtime deps (restricted step - avoids heavy model loads). This ensures the Space runs.
|
| 36 |
+
python -m pip install --upgrade pip
|
| 37 |
+
if [ -f requirements.txt ]; then
|
| 38 |
+
pip install -r requirements.txt
|
| 39 |
+
fi
|
| 40 |
+
|
| 41 |
+
# Run a small smoke-test suite that doesn't pull large models.
|
| 42 |
+
# Ensure emoji mapper and keyword map tests pass quickly.
|
| 43 |
+
python -m pytest avatar/tests/sentiment_emoji_map_test.py::TestEmojiMapper::test_load_emojis -q || (echo "SMOKE TEST FAILED (emoji map)" && exit 1)
|
| 44 |
+
python -m pytest avatar/tests/sentiment_keyword_map_test.py::TestKeywordMap::test_load_emotions -q || (echo "SMOKE TEST FAILED (keyword map)" && exit 1)
|
| 45 |
+
|
| 46 |
+
- name: Configure git
|
| 47 |
+
run: |
|
| 48 |
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
| 49 |
+
git config user.name "github-actions[bot]"
|
| 50 |
+
|
| 51 |
+
- name: Push to Hugging Face Spaces (configured in .hf-config)
|
| 52 |
+
env:
|
| 53 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 54 |
+
run: |
|
| 55 |
+
# Read HF configuration values (supports HF_USERNAME & optional HF_USERNAME_2)
|
| 56 |
+
HF_SPACE_NAME=$(grep '^HF_SPACE_NAME=' .hf-config | cut -d'=' -f2 || true)
|
| 57 |
+
HF_USER_1=$(grep '^HF_USERNAME=' .hf-config | cut -d'=' -f2 || true)
|
| 58 |
+
HF_USER_2=$(grep '^HF_USERNAME_2=' .hf-config | cut -d'=' -f2 || true)
|
| 59 |
+
|
| 60 |
+
if [ -z "$HF_SPACE_NAME" ] || [ -z "$HF_USER_1" ]; then
|
| 61 |
+
echo "ERROR: .hf-config must include HF_USERNAME and HF_SPACE_NAME"
|
| 62 |
+
exit 1
|
| 63 |
+
fi
|
| 64 |
+
|
| 65 |
+
# Push to first target
|
| 66 |
+
echo "Deploying to Space 1: https://huggingface.co/spaces/$HF_USER_1/$HF_SPACE_NAME"
|
| 67 |
+
git remote add space1 "https://$HF_USER_1:[email protected]/spaces/$HF_USER_1/$HF_SPACE_NAME" || true
|
| 68 |
+
git push --force-with-lease space1 main
|
| 69 |
+
echo "Successfully deployed to Space 1."
|
| 70 |
+
|
| 71 |
+
# Push to second target if configured
|
| 72 |
+
if [ -n "$HF_USER_2" ]; then
|
| 73 |
+
echo "Deploying to Space 2: https://huggingface.co/spaces/$HF_USER_2/$HF_SPACE_NAME"
|
| 74 |
+
git remote add space2 "https://$HF_USER_2:[email protected]/spaces/$HF_USER_2/$HF_SPACE_NAME" || true
|
| 75 |
+
git push --force-with-lease space2 main
|
| 76 |
+
echo "Successfully deployed to Space 2."
|
| 77 |
+
else
|
| 78 |
+
echo "No HF_USERNAME_2 found in .hf-config — skipping second target."
|
| 79 |
+
fi
|
| 80 |
+
|
.hf-config
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# HF Space Configuration
|
| 2 |
+
# Used by GitHub Actions workflow to deploy to multiple spaces
|
| 3 |
+
# Deployed to: https://huggingface.co/spaces/NLarchive/Emoji-AI-Avatar
|
| 4 |
+
|
| 5 |
+
HF_USERNAME=NLarchive
|
| 6 |
+
HF_SPACE_NAME=Emoji-AI-Avatar
|
| 7 |
+
# Optional: secondary deployment target.
|
| 8 |
+
# If you want to deploy the same space name to another account, set HF_USERNAME_2.
|
| 9 |
+
# Example:
|
| 10 |
+
# HF_USERNAME_2=YourOtherHFAccount
|