ruslanmv commited on
Commit
1d96f81
Β·
1 Parent(s): e465928

Update sync-to-hf-space.yml

Browse files
.github/workflows/sync-to-hf-space.yml CHANGED
@@ -7,13 +7,9 @@ on:
7
  workflow_dispatch:
8
  inputs:
9
  force:
10
- description: "Force push HEAD to Space main (use for first-time sync or non-fast-forward)"
11
  type: boolean
12
  default: false
13
- ref:
14
- description: "Git ref to push (defaults to current HEAD)"
15
- type: string
16
- default: ""
17
 
18
  jobs:
19
  sync-to-hub:
@@ -22,9 +18,10 @@ jobs:
22
  group: hf-space-sync-matrix-ai
23
  cancel-in-progress: false
24
 
 
25
  env:
26
- # Hard-wired to your Space:
27
- HF_SPACE_REMOTE: https://ruslanmv:${HF_TOKEN}@huggingface.co/spaces/ruslanmv/matrix-ai
28
 
29
  steps:
30
  - name: Checkout
@@ -39,34 +36,31 @@ jobs:
39
  git config user.email "github-actions[bot]@users.noreply.github.com"
40
  git lfs install --local
41
 
42
- - name: Resolve ref to push
43
- id: ref
44
- run: |
45
- REF="${{ inputs.ref }}"
46
- if [ -z "$REF" ]; then
47
- REF="${GITHUB_REF_NAME}"
48
- fi
49
- echo "ref=$REF" >> "$GITHUB_OUTPUT"
50
-
51
  - name: Push to Hugging Face Space (normal)
52
  if: ${{ inputs.force != true }}
53
  env:
54
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
 
 
55
  run: |
56
- if [ -z "${HF_TOKEN}" ]; then
57
  echo "❌ Missing HF_TOKEN secret. Add it under: Settings β†’ Secrets and variables β†’ Actions β†’ New repository secret."
58
  exit 1
59
  fi
60
- # Always push current HEAD to Space's main (handles master→main mapping)
61
- git push "${HF_SPACE_REMOTE}" "HEAD:main"
 
62
 
63
  - name: Push to Hugging Face Space (force)
64
  if: ${{ inputs.force == true }}
65
  env:
66
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
 
 
67
  run: |
68
- if [ -z "${HF_TOKEN}" ]; then
69
  echo "❌ Missing HF_TOKEN secret. Add it under: Settings β†’ Secrets and variables β†’ Actions β†’ New repository secret."
70
  exit 1
71
  fi
72
- git push --force "${HF_SPACE_REMOTE}" "HEAD:main"
 
 
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:
 
18
  group: hf-space-sync-matrix-ai
19
  cancel-in-progress: false
20
 
21
+ # Hard-wire your Space here (or use repo variables if you prefer)
22
  env:
23
+ HF_USERNAME: ruslanmv
24
+ SPACE_NAME: matrix-ai
25
 
26
  steps:
27
  - name: Checkout
 
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
+ HF_USERNAME: ${{ env.HF_USERNAME }}
44
+ SPACE_NAME: ${{ env.SPACE_NAME }}
45
  run: |
46
+ if [ -z "$HF_TOKEN" ]; then
47
  echo "❌ Missing HF_TOKEN secret. Add it under: Settings β†’ Secrets and variables β†’ Actions β†’ New repository secret."
48
  exit 1
49
  fi
50
+ REMOTE_URL="https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"
51
+ # Push current HEAD to Space main (creates main if missing)
52
+ git push "$REMOTE_URL" HEAD:main
53
 
54
  - name: Push to Hugging Face Space (force)
55
  if: ${{ inputs.force == true }}
56
  env:
57
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
58
+ HF_USERNAME: ${{ env.HF_USERNAME }}
59
+ SPACE_NAME: ${{ env.SPACE_NAME }}
60
  run: |
61
+ if [ -z "$HF_TOKEN" ]; then
62
  echo "❌ Missing HF_TOKEN secret. Add it under: Settings β†’ Secrets and variables β†’ Actions β†’ New repository secret."
63
  exit 1
64
  fi
65
+ REMOTE_URL="https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"
66
+ git push --force "$REMOTE_URL" HEAD:main