Abhinav Gavireddi commited on
Commit
422bf2d
·
1 Parent(s): 481c367

fix: fixed issue with pushing codes to HF

Browse files
Files changed (1) hide show
  1. .github/workflows/ci.yaml +16 -12
.github/workflows/ci.yaml CHANGED
@@ -31,36 +31,40 @@ jobs:
31
  - name: Checkout code
32
  uses: actions/checkout@v3
33
  with:
34
- fetch-depth: 0 # Full git history if needed for versioning or changelog
35
 
36
  - name: Set up Python
37
  uses: actions/setup-python@v4
38
  with:
39
- python-version: '3.10' # Use whatever version you prefer
40
 
41
  - name: Install Hugging Face Hub client
42
  run: pip install huggingface_hub
43
 
 
 
 
 
 
44
  - name: Push to Hugging Face Space
45
  env:
46
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
47
  HF_USERNAME: ${{ secrets.HF_USERNAME }}
48
  HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
49
  run: |
50
- echo "Pushing latest code to Hugging Face Space"
51
- git config --global user.email "[email protected]"
52
- git config --global user.name "Abhinav_Gavireddi"
53
 
54
- # Set up Hugging Face CLI
55
- huggingface-cli login --token "$HF_TOKEN"
 
56
 
57
- # Add Hugging Face as remote
58
- git remote add hf https://huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}
59
 
60
- # Push code to the Space repo
 
61
  git push hf main
62
-
63
- # Optional: Restart Space via API (defensive move)
64
  python -c "
65
  from huggingface_hub import HfApi;
66
  api = HfApi(token='$HF_TOKEN');
 
31
  - name: Checkout code
32
  uses: actions/checkout@v3
33
  with:
34
+ fetch-depth: 0 # full history if you need versioning
35
 
36
  - name: Set up Python
37
  uses: actions/setup-python@v4
38
  with:
39
+ python-version: '3.10'
40
 
41
  - name: Install Hugging Face Hub client
42
  run: pip install huggingface_hub
43
 
44
+ - name: Configure Git credential helper
45
+ run: |
46
+ # Use the "store" helper so huggingface-cli can write credentials here
47
+ git config --global credential.helper store
48
+
49
  - name: Push to Hugging Face Space
50
  env:
51
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
52
  HF_USERNAME: ${{ secrets.HF_USERNAME }}
53
  HF_SPACE_NAME: ${{ secrets.HF_SPACE_NAME }}
54
  run: |
55
+ echo "🚀 Pushing code to HF Space..."
 
 
56
 
57
+ # Configure Git identity
58
+ git config --global user.email "github-actions[bot]@users.noreply.github.com"
59
+ git config --global user.name "github-actions[bot]"
60
 
61
+ # Login and add the token to Git credential store
62
+ huggingface-cli login --token "$HF_TOKEN" --add-to-git-credential
63
 
64
+ # Add HF Space repo as remote and push
65
+ git remote add hf https://huggingface.co/spaces/${HF_USERNAME}/${HF_SPACE_NAME}.git
66
  git push hf main
67
+ # Optional: Restart Space via API
 
68
  python -c "
69
  from huggingface_hub import HfApi;
70
  api = HfApi(token='$HF_TOKEN');