Spaces:
Build error
Build error
Commit ·
0ca548a
1
Parent(s): 0c49008
feat: setup GitHub to HuggingFace Spaces CI/CD sync
Browse files- .github/workflows/deploy.yml +28 -35
- requirements.txt +2 -0
.github/workflows/deploy.yml
CHANGED
|
@@ -1,62 +1,55 @@
|
|
| 1 |
# GitHub Actions Deploy Pipeline
|
| 2 |
-
#
|
| 3 |
|
| 4 |
-
name: Deploy
|
| 5 |
|
| 6 |
on:
|
| 7 |
push:
|
| 8 |
branches: [main]
|
| 9 |
workflow_dispatch:
|
| 10 |
|
| 11 |
-
env:
|
| 12 |
-
PYTHON_VERSION: "3.11"
|
| 13 |
-
HF_SPACE: "documind-ai" # Change to your HF username/space
|
| 14 |
-
|
| 15 |
jobs:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
name: Deploy to Hugging Face Spaces
|
| 19 |
runs-on: ubuntu-latest
|
| 20 |
-
if: github.ref == 'refs/heads/main'
|
| 21 |
|
| 22 |
steps:
|
| 23 |
-
- name: Checkout
|
| 24 |
uses: actions/checkout@v4
|
| 25 |
with:
|
| 26 |
fetch-depth: 0
|
| 27 |
lfs: true
|
| 28 |
|
| 29 |
-
- name: Set up Python
|
| 30 |
-
uses: actions/setup-python@v5
|
| 31 |
-
with:
|
| 32 |
-
python-version: ${{ env.PYTHON_VERSION }}
|
| 33 |
-
|
| 34 |
- name: Prepare for HF Spaces
|
| 35 |
run: |
|
| 36 |
-
#
|
| 37 |
cp README_HF.md README.md
|
| 38 |
|
| 39 |
-
# Ensure start
|
| 40 |
chmod +x start.sh
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
-
- name: Push to Hugging Face
|
| 43 |
env:
|
| 44 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 45 |
run: |
|
| 46 |
-
|
| 47 |
-
git
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
needs: [deploy-hf]
|
| 54 |
-
if: always()
|
| 55 |
-
|
| 56 |
-
steps:
|
| 57 |
-
- name: Deployment Status
|
| 58 |
run: |
|
| 59 |
-
echo "
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
|
|
|
|
|
| 1 |
# GitHub Actions Deploy Pipeline
|
| 2 |
+
# Syncs repository to Hugging Face Spaces on merge to main
|
| 3 |
|
| 4 |
+
name: Deploy to Hugging Face Spaces
|
| 5 |
|
| 6 |
on:
|
| 7 |
push:
|
| 8 |
branches: [main]
|
| 9 |
workflow_dispatch:
|
| 10 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
jobs:
|
| 12 |
+
sync-to-huggingface:
|
| 13 |
+
name: Sync to Hugging Face Spaces
|
|
|
|
| 14 |
runs-on: ubuntu-latest
|
|
|
|
| 15 |
|
| 16 |
steps:
|
| 17 |
+
- name: Checkout Repository
|
| 18 |
uses: actions/checkout@v4
|
| 19 |
with:
|
| 20 |
fetch-depth: 0
|
| 21 |
lfs: true
|
| 22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
- name: Prepare for HF Spaces
|
| 24 |
run: |
|
| 25 |
+
# Create HF-compatible README with Space metadata
|
| 26 |
cp README_HF.md README.md
|
| 27 |
|
| 28 |
+
# Ensure start script is executable
|
| 29 |
chmod +x start.sh
|
| 30 |
+
|
| 31 |
+
# Configure git
|
| 32 |
+
git config user.email "github-actions@github.com"
|
| 33 |
+
git config user.name "GitHub Actions"
|
| 34 |
+
|
| 35 |
+
# Commit changes if any
|
| 36 |
+
git add -A
|
| 37 |
+
git diff --staged --quiet || git commit -m "Prepare for HF Spaces deployment"
|
| 38 |
|
| 39 |
+
- name: Push to Hugging Face Hub
|
| 40 |
env:
|
| 41 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 42 |
run: |
|
| 43 |
+
# Add HF remote
|
| 44 |
+
git remote add space https://user:$HF_TOKEN@huggingface.co/spaces/${{ secrets.HF_USERNAME }}/${{ secrets.HF_SPACE_NAME }} || true
|
| 45 |
+
|
| 46 |
+
# Force push to HF Spaces
|
| 47 |
+
git push space main:main --force
|
| 48 |
+
|
| 49 |
+
- name: Deployment Summary
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
run: |
|
| 51 |
+
echo "## 🚀 Deployment Complete!" >> $GITHUB_STEP_SUMMARY
|
| 52 |
+
echo "" >> $GITHUB_STEP_SUMMARY
|
| 53 |
+
echo "✅ Synced to Hugging Face Spaces" >> $GITHUB_STEP_SUMMARY
|
| 54 |
+
echo "" >> $GITHUB_STEP_SUMMARY
|
| 55 |
+
echo "**Space URL:** https://huggingface.co/spaces/${{ secrets.HF_USERNAME }}/${{ secrets.HF_SPACE_NAME }}" >> $GITHUB_STEP_SUMMARY
|
requirements.txt
CHANGED
|
@@ -47,3 +47,5 @@ pytest-asyncio>=0.24.0
|
|
| 47 |
black>=24.0.0
|
| 48 |
isort>=5.13.0
|
| 49 |
mypy>=1.11.0
|
|
|
|
|
|
|
|
|
| 47 |
black>=24.0.0
|
| 48 |
isort>=5.13.0
|
| 49 |
mypy>=1.11.0
|
| 50 |
+
# Markdown Processing (required by unstructured for .md files)
|
| 51 |
+
markdown>=3.5.0
|