ALYYAN commited on
Commit
66221e6
·
unverified ·
1 Parent(s): ae82fc4

Update main.yaml

Browse files
Files changed (1) hide show
  1. .github/workflows/main.yaml +23 -5
.github/workflows/main.yaml CHANGED
@@ -1,4 +1,4 @@
1
- # .github/workflows/main.yml
2
 
3
  name: Deploy App to Hugging Face Spaces
4
 
@@ -12,10 +12,10 @@ jobs:
12
  runs-on: ubuntu-latest
13
 
14
  steps:
15
- - name: Checkout repository
16
  uses: actions/checkout@v4
17
  with:
18
- lfs: true
19
 
20
  - name: Set up Python
21
  uses: actions/setup-python@v5
@@ -36,14 +36,32 @@ jobs:
36
  git config --global user.name "GitHub Actions"
37
 
38
  # Clone the Hugging Face Space using token auth
 
39
  git clone https://user:$HF_TOKEN@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf_space_repo
40
 
41
- # Sync files, excluding .git and workflows
 
42
  rsync -av app/ app.py requirements.txt README.md artifacts/model_training/model/ hf_space_repo/
43
 
 
44
  cd hf_space_repo
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  git add .
46
  git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
47
 
48
- # Push using token auth
 
49
  git push https://user:$HF_TOKEN@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}.git
 
1
+ # .github/workflows/main.yml (Final Version Combining Your Auth and the LFS Fix)
2
 
3
  name: Deploy App to Hugging Face Spaces
4
 
 
12
  runs-on: ubuntu-latest
13
 
14
  steps:
15
+ - name: Checkout repository from GitHub
16
  uses: actions/checkout@v4
17
  with:
18
+ lfs: true # Ensures the large model file is downloaded here
19
 
20
  - name: Set up Python
21
  uses: actions/setup-python@v5
 
36
  git config --global user.name "GitHub Actions"
37
 
38
  # Clone the Hugging Face Space using token auth
39
+ echo "Cloning target HF Space..."
40
  git clone https://user:$HF_TOKEN@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf_space_repo
41
 
42
+ # Sync application files into the cloned repo
43
+ echo "Syncing files..."
44
  rsync -av app/ app.py requirements.txt README.md artifacts/model_training/model/ hf_space_repo/
45
 
46
+ # Navigate into the cloned repo
47
  cd hf_space_repo
48
+
49
+ # --- THIS IS THE CRUCIAL MISSING STEP ---
50
+ echo "Configuring Git LFS for push..."
51
+ # 1. Install LFS (it's pre-installed on runners, but `install` activates it)
52
+ git lfs install
53
+ # 2. Tell LFS to track the large file types in this repo
54
+ git lfs track "*.safetensors"
55
+ git lfs track "*.pt"
56
+ git lfs track "*.bin"
57
+ # 3. Ensure the .gitattributes file is staged
58
+ git add .gitattributes
59
+
60
+ echo "Committing changes..."
61
+ # Now, add all the synced files
62
  git add .
63
  git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
64
 
65
+ # Push using token auth. LFS will now intercept the large files.
66
+ echo "Pushing to HF Space..."
67
  git push https://user:$HF_TOKEN@huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}.git