ALYYAN commited on
Commit
03d16a6
·
unverified ·
1 Parent(s): 9047e5e

Update main.yaml

Browse files
Files changed (1) hide show
  1. .github/workflows/main.yaml +27 -14
.github/workflows/main.yaml CHANGED
@@ -1,4 +1,4 @@
1
- # .github/workflows/main.yml (Final, Git LFS Version)
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. `lfs: true` is crucial.
16
  - name: Checkout repository
17
  uses: actions/checkout@v4
18
  with:
19
- lfs: true # This automatically pulls your Git LFS files (the model)
20
 
21
- # Step 2: Log in to Hugging Face Hub
22
- - name: Log in to Hugging Face Hub
23
- uses: huggingface-hub/login@v1
24
  with:
25
- token: ${{ secrets.HF_TOKEN }}
 
 
 
 
 
 
 
 
 
 
 
26
 
27
- # Step 3: Push the complete app to the Space
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
- # Clone the Space repo into a new directory
36
- git clone https://huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf_space_repo
37
- # Copy all necessary files into the Space repo
38
- rsync -av --delete app/ app.py requirements.txt README.md artifacts/model_training/model/ hf_space_repo/
 
 
 
39
  cd hf_space_repo
40
  git add .
41
  git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
42
- # Force push is safer here to ensure the Space exactly matches the repo
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