Spaces:
Sleeping
Sleeping
Update main.yaml
Browse files- .github/workflows/main.yaml +27 -14
.github/workflows/main.yaml
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
# .github/workflows/main.yml (Final,
|
| 2 |
|
| 3 |
name: Deploy App to Hugging Face Spaces
|
| 4 |
|
|
@@ -12,19 +12,30 @@ jobs:
|
|
| 12 |
runs-on: ubuntu-latest
|
| 13 |
|
| 14 |
steps:
|
| 15 |
-
# Step 1: Check out your repo
|
| 16 |
- name: Checkout repository
|
| 17 |
uses: actions/checkout@v4
|
| 18 |
with:
|
| 19 |
-
lfs: true
|
| 20 |
|
| 21 |
-
# Step 2:
|
| 22 |
-
- name:
|
| 23 |
-
uses:
|
| 24 |
with:
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
# Step
|
| 28 |
- name: Push to HF Space
|
| 29 |
env:
|
| 30 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
|
@@ -32,12 +43,14 @@ jobs:
|
|
| 32 |
run: |
|
| 33 |
git config --global user.email "action@github.com"
|
| 34 |
git config --global user.name "GitHub Action"
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
|
|
|
|
|
|
|
|
|
| 39 |
cd hf_space_repo
|
| 40 |
git add .
|
| 41 |
git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
|
| 42 |
-
|
| 43 |
-
git push --force
|
|
|
|
| 1 |
+
# .github/workflows/main.yml (Final, Most Robust 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 repo, including LFS files
|
| 16 |
- name: Checkout repository
|
| 17 |
uses: actions/checkout@v4
|
| 18 |
with:
|
| 19 |
+
lfs: true
|
| 20 |
|
| 21 |
+
# Step 2: Set up Python
|
| 22 |
+
- name: Set up Python
|
| 23 |
+
uses: actions/setup-python@v5
|
| 24 |
with:
|
| 25 |
+
python-version: '3.11'
|
| 26 |
+
|
| 27 |
+
# Step 3: Install requirements (huggingface_hub is in requirements.txt)
|
| 28 |
+
- name: Install dependencies
|
| 29 |
+
run: pip install -r requirements.txt
|
| 30 |
+
|
| 31 |
+
# Step 4: Log in to Hugging Face Hub using the CLI
|
| 32 |
+
# THIS IS THE FIX. It is more reliable than the 'uses:' action.
|
| 33 |
+
- name: Log in to Hugging Face Hub
|
| 34 |
+
env:
|
| 35 |
+
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
| 36 |
+
run: huggingface-cli login --token $HF_TOKEN
|
| 37 |
|
| 38 |
+
# Step 5: Push the complete app to the Space
|
| 39 |
- name: Push to HF Space
|
| 40 |
env:
|
| 41 |
HF_USERNAME: ${{ secrets.HF_USERNAME }}
|
|
|
|
| 43 |
run: |
|
| 44 |
git config --global user.email "action@github.com"
|
| 45 |
git config --global user.name "GitHub Action"
|
| 46 |
+
|
| 47 |
+
# Use the HF_TOKEN for authentication with the Space repo
|
| 48 |
+
git clone https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf_space_repo
|
| 49 |
+
|
| 50 |
+
# Use rsync to sync files efficiently
|
| 51 |
+
rsync -av --delete --exclude='.git/' ./ hf_space_repo/
|
| 52 |
+
|
| 53 |
cd hf_space_repo
|
| 54 |
git add .
|
| 55 |
git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
|
| 56 |
+
git push
|
|
|