ruslanmv commited on
Commit
7321ead
Β·
1 Parent(s): 1bdf82a

Update sync-to-hf-space.yml

Browse files
.github/workflows/sync-to-hf-space.yml CHANGED
@@ -4,12 +4,7 @@ name: Sync to Hugging Face Space (matrix-ai)
4
  on:
5
  push:
6
  branches: ["main", "master"]
7
- workflow_dispatch:
8
- inputs:
9
- force:
10
- description: "Force push HEAD to Space main (first sync or non-FF)"
11
- type: boolean
12
- default: false
13
 
14
  jobs:
15
  sync-to-hub:
@@ -36,8 +31,7 @@ jobs:
36
  git config user.email "github-actions[bot]@users.noreply.github.com"
37
  git lfs install --local
38
 
39
- - name: Push to Hugging Face Space (normal)
40
- if: ${{ inputs.force != true }}
41
  env:
42
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
43
  run: |
@@ -50,23 +44,10 @@ jobs:
50
  # Build the authenticated remote URL *inside* the step so the secret expands.
51
  REMOTE_URL="https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"
52
 
53
- # Try a normal fast-forward push: HEAD -> main (creates main if missing).
54
- if ! git push "$REMOTE_URL" HEAD:main; then
55
- echo "::error::Non-fast-forward (remote has commits you don't)."
56
- echo " If GitHub is the source of truth, rerun this workflow with 'force: true'."
57
- echo " Or fetch Space changes locally, merge into your GitHub branch, then push again."
58
- exit 1
59
- fi
60
-
61
- - name: Push to Hugging Face Space (force)
62
- if: ${{ inputs.force == true }}
63
- env:
64
- HF_TOKEN: ${{ secrets.HF_TOKEN }}
65
- run: |
66
- set -e
67
- if [ -z "$HF_TOKEN" ]; then
68
- echo "❌ Missing HF_TOKEN secret. Add it under: Settings β†’ Secrets and variables β†’ Actions β†’ New repository secret."
69
- exit 1
70
- fi
71
- REMOTE_URL="https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"
72
  git push --force "$REMOTE_URL" HEAD:main
 
 
 
 
 
 
4
  on:
5
  push:
6
  branches: ["main", "master"]
7
+ workflow_dispatch: {} # optional manual run
 
 
 
 
 
8
 
9
  jobs:
10
  sync-to-hub:
 
31
  git config user.email "github-actions[bot]@users.noreply.github.com"
32
  git lfs install --local
33
 
34
+ - name: Force push GitHub β†’ Hugging Face Space (GitHub is source of truth)
 
35
  env:
36
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
37
  run: |
 
44
  # Build the authenticated remote URL *inside* the step so the secret expands.
45
  REMOTE_URL="https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"
46
 
47
+ echo "πŸ” Forcing HEAD β†’ Space main (GitHub is the source of truth)..."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  git push --force "$REMOTE_URL" HEAD:main
49
+
50
+ # Best-effort push for LFS objects (won't fail the job if none)
51
+ git lfs push --all "$REMOTE_URL" main || true
52
+
53
+ echo "βœ… Sync complete: GitHub HEAD is now Space main."