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

fix: nova tentativa

Browse files
.github/workflows/sync-to-huggingface.yml CHANGED
@@ -15,43 +15,36 @@ jobs:
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
 
 
 
15
  fetch-depth: 0
16
  lfs: true
17
 
 
 
 
 
 
18
  - name: Set up SSH
19
  run: |
 
20
  mkdir -p ~/.ssh
21
  echo "${{ secrets.HF_SSH_PRIVATE_KEY }}" > ~/.ssh/custom_key
22
  chmod 600 ~/.ssh/custom_key
 
 
 
 
 
 
 
23
  ssh-keyscan huggingface.co >> ~/.ssh/known_hosts
24
 
25
+ # Force Git to use SSH for Hugging Face URLs
26
+ git config --global url."[email protected]:".insteadOf "https://huggingface.co/"
27
+
28
+ # Update or add remotes
29
+ git remote add space [email protected]:spaces/luanpoppe/vella-backend.git 2> /dev/null || git remote set-url space [email protected]:spaces/luanpoppe/vella-backend.git
30
+ git remote add tests [email protected]:spaces/luanpoppe/vella-backend-tests.git 2> /dev/null || git remote set-url tests [email protected]:spaces/luanpoppe/vella-backend-tests.git
31
 
32
+ - name: Test SSH Authentication
33
+ run: |
34
+ echo "Testing SSH connection to Hugging Face:"
35
+ ssh -T -i ~/.ssh/custom_key [email protected]
36
 
37
+ - name: Push Changes
38
  run: |
39
  if [[ $GITHUB_REF == "refs/heads/main" ]]; then
40
+ REMOTE="space"
41
  elif [[ $GITHUB_REF == "refs/heads/tests" ]]; then
42
+ REMOTE="tests"
43
  else
44
+ echo "Branch not configured"
45
  exit 1
46
  fi
47
 
48
+ git config --global user.name "GitHub Actions"
49
+ git config --global user.email "[email protected]"
50
+ GIT_SSH_COMMAND="ssh -i ~/.ssh/custom_key" git push $REMOTE HEAD:main --force