Akshit Chaturvedi commited on
Commit
f8d4216
·
1 Parent(s): a3a6afc

updated script

Browse files
.github/workflows/sync-to-hf-space.yml CHANGED
@@ -4,7 +4,7 @@ name: Sync to Hugging Face Space
4
  on:
5
  push:
6
  branches:
7
- - main # Or whatever your default branch is
8
 
9
  jobs:
10
  sync:
@@ -13,28 +13,30 @@ jobs:
13
  - name: Checkout repository
14
  uses: actions/checkout@v3
15
  with:
16
- fetch-depth: 0 # Fetch all history for accurate diffs
 
17
 
18
  - name: Push to Hugging Face Space
19
  env:
20
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
21
- # Your Hugging Face username
22
  HF_USERNAME: GuitarGeorge
23
- # The ID of your Space (username/space-name)
24
  SPACE_ID: GuitarGeorge/Neural-Prophet-Predictor
25
  run: |
26
  echo "Attempting to push to Hugging Face Space: $SPACE_ID"
27
- # Add Hugging Face as a remote
28
- git remote add hf_space "https://dummy:${HF_TOKEN}@huggingface.co/spaces/${SPACE_ID}"
29
-
30
- # Check if the remote was added
31
- git remote -v
32
 
33
  # Configure Git user
34
  git config --global user.email "action@github.com"
35
  git config --global user.name "GitHub Action"
 
 
 
 
 
 
 
36
 
37
  # Force push to ensure the Space mirrors GitHub
 
38
  git push --force hf_space HEAD:refs/heads/main
39
 
40
  echo "Push to Hugging Face Space completed."
 
4
  on:
5
  push:
6
  branches:
7
+ - main
8
 
9
  jobs:
10
  sync:
 
13
  - name: Checkout repository
14
  uses: actions/checkout@v3
15
  with:
16
+ fetch-depth: 0
17
+ lfs: true # Enable LFS if you have large files
18
 
19
  - name: Push to Hugging Face Space
20
  env:
21
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
 
22
  HF_USERNAME: GuitarGeorge
 
23
  SPACE_ID: GuitarGeorge/Neural-Prophet-Predictor
24
  run: |
25
  echo "Attempting to push to Hugging Face Space: $SPACE_ID"
 
 
 
 
 
26
 
27
  # Configure Git user
28
  git config --global user.email "action@github.com"
29
  git config --global user.name "GitHub Action"
30
+
31
+ # Add Hugging Face as a remote using the actual username and token
32
+ # We use the format https://USERNAME:TOKEN@huggingface.co/spaces/SPACE_ID
33
+ git remote add hf_space "https://$HF_USERNAME:$HF_TOKEN@huggingface.co/spaces/$SPACE_ID"
34
+
35
+ # clear any weird credential helpers
36
+ git config --global --unset credential.helper || true
37
 
38
  # Force push to ensure the Space mirrors GitHub
39
+ # We redirect output to /dev/null to prevent the token from leaking in logs if git throws an error printing the URL
40
  git push --force hf_space HEAD:refs/heads/main
41
 
42
  echo "Push to Hugging Face Space completed."