alexdum commited on
Commit
c1c88c0
·
unverified ·
1 Parent(s): 4a19d3b

Create main.yml

Browse files
Files changed (1) hide show
  1. .github/workflows/main.yml +63 -0
.github/workflows/main.yml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face Hub
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ workflow_dispatch:
7
+
8
+ jobs:
9
+ sync-to-hub:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ # Step 1: Checkout the repository with full history and LFS support
13
+ - uses: actions/checkout@v3
14
+ with:
15
+ fetch-depth: 0
16
+ lfs: true
17
+
18
+ # Step 2: Configure Git User (necessary for commits)
19
+ - name: Configure Git User
20
+ run: |
21
+ git config --global user.email "alexandru.dumitrescu@gmail.com"
22
+ git config --global user.name "alexdum"
23
+
24
+ # Step 3a: Track .nc Files with Git LFS if not already tracked
25
+ - name: Track .csv Files with Git LFS
26
+ run: |
27
+ if ! grep -q "*.csv" .gitattributes; then
28
+ git lfs track "*.csv"
29
+ git add .gitattributes
30
+ git commit -m "Configure Git LFS for all .csv files"
31
+ fi
32
+ # Step 3b: Track .parquet Files with Git LFS if not already tracked
33
+ - name: Track .parquet Files with Git LFS
34
+ run: |
35
+ if ! grep -q "*.parquet" .gitattributes; then
36
+ git lfs track "*.parquet"
37
+ git add .gitattributes
38
+ git commit -m "Configure Git LFS for all .parquet files"
39
+ fi
40
+
41
+ # Step 4: Add and Commit Any LFS-tracked Files (only if there are changes)
42
+ - name: Add and Commit LFS-tracked Files
43
+ run: |
44
+ git add .
45
+ git diff-index --quiet HEAD || git commit -m "Move .nc files to Git LFS"
46
+
47
+ # Step 5: Verify LFS Tracking
48
+ - name: Verify LFS Tracking
49
+ run: git lfs ls-files
50
+
51
+ # Step 6: Add Hugging Face Remote
52
+ - name: Add Hugging Face Remote
53
+ env:
54
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
55
+ run: |
56
+ git remote add hf https://alexdum:${HF_TOKEN}@huggingface.co/spaces/alexdum/ghcnm
57
+
58
+ # Step 7: Force Push to Hugging Face Hub
59
+ - name: Force Push to Hugging Face Hub
60
+ env:
61
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
62
+ run: |
63
+ git push hf main --force