luanpoppe commited on
Commit
8836d9d
·
1 Parent(s): e9a035c

fix: new possible fix

Browse files
.github/workflows/sync-to-huggingface.yml CHANGED
@@ -3,8 +3,8 @@ name: Sync to Hugging Face Spaces with SSH
3
  on:
4
  push:
5
  branches:
6
- - main # Push to the first Space when main is updated
7
- - tests # Push to the second Space when tests is updated
8
 
9
  jobs:
10
  sync-to-hub:
@@ -15,41 +15,43 @@ jobs:
15
  fetch-depth: 0
16
  lfs: true
17
 
 
 
 
 
 
18
  - name: Set up SSH
19
  run: |
20
- # Create .ssh directory and configure key
21
  mkdir -p ~/.ssh
22
  echo "${{ secrets.HF_SSH_PRIVATE_KEY }}" > ~/.ssh/custom_key
23
  chmod 600 ~/.ssh/custom_key
24
- ssh-keyscan huggingface.co >> ~/.ssh/known_hosts
25
 
26
- # Debug: List remotes before modification
27
- echo "Remotes before update:"
28
- git remote -v
 
29
 
30
- # Add or update remotes with explicit error handling
31
- git remote add space git@huggingface.co:spaces/luanpoppe/vella-backend.git || true
32
- git remote set-url space [email protected]:spaces/luanpoppe/vella-backend.git || true
33
 
 
 
 
34
  git remote add tests [email protected]:spaces/luanpoppe/vella-backend-tests.git || true
35
- git remote set-url tests [email protected]:spaces/luanpoppe/vella-backend-tests.git || true
36
 
37
- # Debug: List remotes after modification
38
- echo "Remotes after update:"
39
  git remote -v
40
 
41
- - name: Determine target remote
42
- id: determine_remote
43
  run: |
44
  if [[ $GITHUB_REF == "refs/heads/main" ]]; then
45
- echo "TARGET_REMOTE=space" >> $GITHUB_ENV
46
  elif [[ $GITHUB_REF == "refs/heads/tests" ]]; then
47
- echo "TARGET_REMOTE=tests" >> $GITHUB_ENV
48
  else
49
  echo "Branch not configured for sync"
50
  exit 1
51
  fi
52
 
53
- - name: Push to Hugging Face Space
54
- run: |
55
  GIT_SSH_COMMAND="ssh -i ~/.ssh/custom_key" git push $TARGET_REMOTE HEAD:main --force
 
3
  on:
4
  push:
5
  branches:
6
+ - main
7
+ - tests
8
 
9
  jobs:
10
  sync-to-hub:
 
15
  fetch-depth: 0
16
  lfs: true
17
 
18
+ - name: Install SSH dependencies
19
+ run: |
20
+ sudo apt-get update
21
+ sudo apt-get install -y openssh-client # Fix: Ensure ssh-keyscan is available
22
+
23
  - name: Set up SSH
24
  run: |
25
+ # Create .ssh directory and key
26
  mkdir -p ~/.ssh
27
  echo "${{ secrets.HF_SSH_PRIVATE_KEY }}" > ~/.ssh/custom_key
28
  chmod 600 ~/.ssh/custom_key
 
29
 
30
+ # Verify key file exists
31
+ echo "Key file contents (first 50 chars):"
32
+ head -c 50 ~/.ssh/custom_key || true
33
+ echo ""
34
 
35
+ # Add Hugging Face to known_hosts
36
+ ssh-keyscan huggingface.co >> ~/.ssh/known_hosts
 
37
 
38
+ # Configure Git remotes
39
+ git config --global url."[email protected]:".insteadOf "https://huggingface.co/" # Force SSH for all Hugging Face URLs
40
+ git remote add space [email protected]:spaces/luanpoppe/vella-backend.git || true
41
  git remote add tests [email protected]:spaces/luanpoppe/vella-backend-tests.git || true
 
42
 
43
+ # Debug remotes
 
44
  git remote -v
45
 
46
+ - name: Push to Hugging Face Space
 
47
  run: |
48
  if [[ $GITHUB_REF == "refs/heads/main" ]]; then
49
+ TARGET_REMOTE="space"
50
  elif [[ $GITHUB_REF == "refs/heads/tests" ]]; then
51
+ TARGET_REMOTE="tests"
52
  else
53
  echo "Branch not configured for sync"
54
  exit 1
55
  fi
56
 
 
 
57
  GIT_SSH_COMMAND="ssh -i ~/.ssh/custom_key" git push $TARGET_REMOTE HEAD:main --force