ALYYAN commited on
Commit
9047e5e
·
unverified ·
1 Parent(s): 31f840b

Update main.yaml

Browse files
Files changed (1) hide show
  1. .github/workflows/main.yaml +12 -30
.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,40 +12,19 @@ jobs:
12
  runs-on: ubuntu-latest
13
 
14
  steps:
 
15
  - name: Checkout repository
16
  uses: actions/checkout@v4
17
  with:
18
- fetch-depth: 0
19
-
20
- - name: Set up Python
21
- uses: actions/setup-python@v5
22
- with:
23
- python-version: '3.11'
24
-
25
- - name: Install DVC and project requirements
26
- run: |
27
- pip install "dvc[gdrive]"
28
- pip install -r requirements.txt
29
-
30
- - name: Configure DVC
31
- env:
32
- GDRIVE_CREDENTIALS_DATA: ${{ secrets.GDRIVE_CREDENTIALS_DATA }}
33
- run: |
34
- mkdir -p .dvc/tmp
35
- echo "$GDRIVE_CREDENTIALS_DATA" > .dvc/tmp/gdrive-user-credentials.json
36
-
37
- # --- THIS IS THE FIX ---
38
- - name: Pull DVC Artifacts
39
- # We specify the stage name directly as a target, without the -s flag
40
- run: dvc pull model_training -f
41
 
 
42
  - name: Log in to Hugging Face Hub
43
- env:
44
- HF_TOKEN: ${{ secrets.HF_TOKEN }}
45
- run: |
46
- pip install huggingface_hub
47
- huggingface-cli login --token $HF_TOKEN
48
 
 
49
  - name: Push to HF Space
50
  env:
51
  HF_USERNAME: ${{ secrets.HF_USERNAME }}
@@ -53,9 +32,12 @@ jobs:
53
  run: |
54
  git config --global user.email "action@github.com"
55
  git config --global user.name "GitHub Action"
 
56
  git clone https://huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME} hf_space_repo
 
57
  rsync -av --delete app/ app.py requirements.txt README.md artifacts/model_training/model/ hf_space_repo/
58
  cd hf_space_repo
59
  git add .
60
  git commit -m "Automatic deployment from GitHub Action" || echo "No changes to commit"
61
- git push
 
 
1
+ # .github/workflows/main.yml (Final, Git LFS 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. `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
  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