Claude commited on
Commit
6662cc9
·
unverified ·
1 Parent(s): 87b6aef

Fix GitHub Actions workflow: Update Hugging Face CLI commands

Browse files

- Install huggingface_hub[cli] instead of just huggingface_hub
- Use 'hf auth login' instead of deprecated 'huggingface-cli login'
- Add token-based URL authentication for git push
- Add better logging with emoji indicators
- Ensure compatibility with latest huggingface_hub package

This fixes the "huggingface-cli: command not found" error in GitHub Actions.

Files changed (1) hide show
  1. .github/workflows/sync-to-hub.yml +16 -5
.github/workflows/sync-to-hub.yml CHANGED
@@ -25,15 +25,12 @@ jobs:
25
 
26
  - name: Install Hugging Face CLI
27
  run: |
28
- pip install --upgrade huggingface_hub
29
 
30
  - name: Push to Hugging Face Spaces
31
  env:
32
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
33
  run: |
34
- # Hugging Face にログイン
35
- huggingface-cli login --token $HF_TOKEN --add-to-git-credential
36
-
37
  # Spaces リポジトリのURL
38
  SPACE_URL="https://huggingface.co/spaces/YUGOROU/ml-sharp_ZeroGPU"
39
 
@@ -41,9 +38,23 @@ jobs:
41
  git config --global user.email "github-actions[bot]@users.noreply.github.com"
42
  git config --global user.name "github-actions[bot]"
43
 
 
 
 
 
 
 
 
 
44
  # Hugging Face Spacesにpush
 
45
  git remote add hf https://huggingface.co/spaces/YUGOROU/ml-sharp_ZeroGPU || true
46
- git push hf main --force
 
 
 
 
 
47
 
48
  echo "✅ Successfully synced to Hugging Face Spaces!"
49
  echo "🚀 Space URL: $SPACE_URL"
 
25
 
26
  - name: Install Hugging Face CLI
27
  run: |
28
+ pip install --upgrade "huggingface_hub[cli]"
29
 
30
  - name: Push to Hugging Face Spaces
31
  env:
32
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
33
  run: |
 
 
 
34
  # Spaces リポジトリのURL
35
  SPACE_URL="https://huggingface.co/spaces/YUGOROU/ml-sharp_ZeroGPU"
36
 
 
38
  git config --global user.email "github-actions[bot]@users.noreply.github.com"
39
  git config --global user.name "github-actions[bot]"
40
 
41
+ # Hugging Face にログイン (最新のコマンド)
42
+ echo "🔐 Logging in to Hugging Face..."
43
+ hf auth login --token $HF_TOKEN --add-to-git-credential
44
+
45
+ # 現在のブランチ名を取得
46
+ CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
47
+ echo "📍 Current branch: $CURRENT_BRANCH"
48
+
49
  # Hugging Face Spacesにpush
50
+ echo "📤 Pushing to Hugging Face Spaces..."
51
  git remote add hf https://huggingface.co/spaces/YUGOROU/ml-sharp_ZeroGPU || true
52
+
53
+ # トークンを使用してURL認証を設定
54
+ git remote set-url hf https://user:${HF_TOKEN}@huggingface.co/spaces/YUGOROU/ml-sharp_ZeroGPU
55
+
56
+ # mainブランチにpush
57
+ git push hf HEAD:main --force
58
 
59
  echo "✅ Successfully synced to Hugging Face Spaces!"
60
  echo "🚀 Space URL: $SPACE_URL"