Spaces:
Sleeping
Sleeping
Update main.yaml
Browse files- .github/workflows/main.yaml +15 -40
.github/workflows/main.yaml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# .github/workflows/main.yml (Final Version
|
| 2 |
|
| 3 |
name: Deploy App to Hugging Face Spaces
|
| 4 |
|
|
@@ -12,57 +12,32 @@ jobs:
|
|
| 12 |
runs-on: ubuntu-latest
|
| 13 |
|
| 14 |
steps:
|
| 15 |
-
|
|
|
|
| 16 |
uses: actions/checkout@v4
|
| 17 |
-
with:
|
| 18 |
-
lfs: true # Ensures the large model file is downloaded here
|
| 19 |
-
token: ${{ secrets.GITHUB_TOKEN }}
|
| 20 |
-
|
| 21 |
-
- name: Set up Python
|
| 22 |
-
uses: actions/setup-python@v5
|
| 23 |
-
with:
|
| 24 |
-
python-version: '3.11'
|
| 25 |
-
|
| 26 |
-
- name: Install dependencies
|
| 27 |
-
run: pip install -r requirements.txt
|
| 28 |
|
|
|
|
|
|
|
|
|
|
| 29 |
- name: Push to HF Space
|
| 30 |
env:
|
| 31 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 32 |
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
|
| 33 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 34 |
run: |
|
| 35 |
-
# Configure git identity
|
| 36 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 37 |
-
git config --global user.name "GitHub
|
| 38 |
-
|
| 39 |
-
# Clone the Hugging Face Space using token auth
|
| 40 |
echo "Cloning target HF Space..."
|
| 41 |
git clone https://user:$HF_TOKEN@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf_space_repo
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
rsync -av app/ app.py requirements.txt README.md
|
| 46 |
-
|
| 47 |
-
# Navigate into the cloned repo
|
| 48 |
cd hf_space_repo
|
| 49 |
-
|
| 50 |
-
# --- THIS IS THE CRUCIAL MISSING STEP ---
|
| 51 |
-
echo "Configuring Git LFS for push..."
|
| 52 |
-
# 1. Install LFS (it's pre-installed on runners, but `install` activates it)
|
| 53 |
-
git lfs install
|
| 54 |
-
# 2. Tell LFS to track the large file types in this repo
|
| 55 |
-
git lfs track "*.safetensors"
|
| 56 |
-
git lfs track "*.pt"
|
| 57 |
-
git lfs track "*.bin"
|
| 58 |
-
# 3. Ensure the .gitattributes file is staged
|
| 59 |
-
git add .gitattributes
|
| 60 |
|
| 61 |
-
echo "Committing
|
| 62 |
-
# Now, add all the synced files
|
| 63 |
git add .
|
| 64 |
git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
|
| 65 |
-
|
| 66 |
-
# Push using token auth. LFS will now intercept the large files.
|
| 67 |
-
echo "Pushing to HF Space..."
|
| 68 |
-
git push https://user:$HF_TOKEN@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}.git
|
|
|
|
| 1 |
+
# .github/workflows/main.yml (Final, Simplified Version)
|
| 2 |
|
| 3 |
name: Deploy App to Hugging Face Spaces
|
| 4 |
|
|
|
|
| 12 |
runs-on: ubuntu-latest
|
| 13 |
|
| 14 |
steps:
|
| 15 |
+
# Step 1: Check out your app's source code (no LFS needed)
|
| 16 |
+
- name: Checkout repository
|
| 17 |
uses: actions/checkout@v4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
# Step 2: Push to HF Space
|
| 20 |
+
# This step copies ONLY your application code. The model will be
|
| 21 |
+
# downloaded by the app itself when the Space starts.
|
| 22 |
- name: Push to HF Space
|
| 23 |
env:
|
| 24 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
| 25 |
HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
|
| 26 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 27 |
run: |
|
|
|
|
| 28 |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
|
| 29 |
+
git config --global user.name "GitHub Action"
|
| 30 |
+
|
|
|
|
| 31 |
echo "Cloning target HF Space..."
|
| 32 |
git clone https://user:$HF_TOKEN@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf_space_repo
|
| 33 |
+
|
| 34 |
+
echo "Syncing application files..."
|
| 35 |
+
# Note: We are NO LONGER copying the 'artifacts' folder
|
| 36 |
+
rsync -av --delete --exclude='.git/' app/ app.py requirements.txt README.md setup.sh hf_space_repo/
|
| 37 |
+
|
|
|
|
| 38 |
cd hf_space_repo
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
+
echo "Committing and pushing to Space..."
|
|
|
|
| 41 |
git add .
|
| 42 |
git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
|
| 43 |
+
git push
|
|
|
|
|
|
|
|
|