rjorgec commited on
Commit
bbcab26
·
unverified ·
1 Parent(s): b343aab

Update main.yml

Browse files
Files changed (1) hide show
  1. .github/workflows/main.yml +25 -10
.github/workflows/main.yml CHANGED
@@ -2,27 +2,42 @@ name: Sync to Hugging Face hub
2
  on:
3
  push:
4
  branches: [main]
5
-
6
- # to run this workflow manually from the Actions tab
7
  workflow_dispatch:
8
 
9
  jobs:
10
  sync-to-hub:
11
  runs-on: ubuntu-latest
12
  steps:
13
- - uses: actions/checkout@v3
14
  with:
15
  fetch-depth: 0
16
  lfs: true
17
 
18
- - name: Push to hub (with rebase)
19
- env:
20
- HF_TOKEN: ${{ secrets.HF_TOKEN }}
21
  run: |
22
- set -euo pipefail
23
- HF_URL="https://rjorgec:${HF_TOKEN}@huggingface.co/spaces/DS553-Music-Bot/ChordBot"
24
  git config user.name "github-actions[bot]"
25
  git config user.email "github-actions[bot]@users.noreply.github.com"
26
  git lfs install --local
27
- git pull --rebase "$HF_URL" main || true
28
- git push "$HF_URL" main
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  on:
3
  push:
4
  branches: [main]
 
 
5
  workflow_dispatch:
6
 
7
  jobs:
8
  sync-to-hub:
9
  runs-on: ubuntu-latest
10
  steps:
11
+ - uses: actions/checkout@v4
12
  with:
13
  fetch-depth: 0
14
  lfs: true
15
 
16
+ - name: Configure git
 
 
17
  run: |
 
 
18
  git config user.name "github-actions[bot]"
19
  git config user.email "github-actions[bot]@users.noreply.github.com"
20
  git lfs install --local
21
+
22
+ - name: Add HF remote
23
+ env:
24
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
25
+ run: |
26
+ HF_URL="https://rjorgec:${HF_TOKEN}@huggingface.co/spaces/DS553-Music-Bot/ChordBot"
27
+ if git remote get-url hf >/dev/null 2>&1; then
28
+ git remote set-url hf "$HF_URL"
29
+ else
30
+ git remote add hf "$HF_URL"
31
+ fi
32
+
33
+ # One-time history stitch: keep *your* files, acknowledge HF history.
34
+ - name: Merge hf/main (prefer ours) and push
35
+ run: |
36
+ set -euo pipefail
37
+ if git ls-remote --exit-code --heads hf main >/dev/null 2>&1; then
38
+ git fetch hf main
39
+ # Create a merge commit that includes hf/main’s history but keeps our content
40
+ git merge -s ours --allow-unrelated-histories hf/main -m "CI: stitch histories (keep repo content)"
41
+ fi
42
+ # Fast-forward push; --with-lease protects against races
43
+ git push hf main --force-with-lease