rjorgec commited on
Commit
2482e26
·
unverified ·
1 Parent(s): 9c0469c

Create main.yml

Browse files
Files changed (1) hide show
  1. .github/workflows/main.yml +43 -0
.github/workflows/main.yml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face hub
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-API"
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