gavinzli commited on
Commit
da6fc10
·
1 Parent(s): 8da4dd1

Refactor GitHub Actions workflow for Hugging Face sync; improve Git LFS handling and streamline large file commits

Browse files
Files changed (1) hide show
  1. .github/workflows/main.yml +22 -11
.github/workflows/main.yml CHANGED
@@ -1,10 +1,8 @@
1
- name: Sync to Hugging Face hub
2
 
3
  on:
4
  push:
5
  branches: [main]
6
-
7
- # To run this workflow manually from the Actions tab
8
  workflow_dispatch:
9
 
10
  jobs:
@@ -17,11 +15,11 @@ jobs:
17
  fetch-depth: 0
18
  lfs: true # Enable Git LFS support
19
 
20
- # Install Git LFS to handle large files
21
  - name: Install Git LFS
22
  run: |
23
  sudo apt-get update
24
- sudo apt-get install git-lfs
25
  git lfs install
26
 
27
  # Set Git user identity
@@ -30,12 +28,25 @@ jobs:
30
  git config --global user.email "[email protected]"
31
  git config --global user.name "GitHub Actions Bot"
32
 
33
- # Track large files and push them to the Hugging Face Hub
34
- - name: Push to hub
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  env:
36
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
37
  run: |
38
- git lfs track "*.sqlite3" # Replace with the extension(s) of your large files
39
- git add .
40
- git commit -m "Add large files"
41
- git push https://OxbridegeEcon:[email protected]/spaces/Oxbridge-Economics/Mailbox main --force
 
1
+ name: Sync to Hugging Face Hub
2
 
3
  on:
4
  push:
5
  branches: [main]
 
 
6
  workflow_dispatch:
7
 
8
  jobs:
 
15
  fetch-depth: 0
16
  lfs: true # Enable Git LFS support
17
 
18
+ # Install Git LFS
19
  - name: Install Git LFS
20
  run: |
21
  sudo apt-get update
22
+ sudo apt-get install git-lfs -y
23
  git lfs install
24
 
25
  # Set Git user identity
 
28
  git config --global user.email "[email protected]"
29
  git config --global user.name "GitHub Actions Bot"
30
 
31
+ # Ensure large files are tracked (only if not already tracked)
32
+ - name: Track large files with Git LFS
33
+ run: |
34
+ if ! grep -q "*.sqlite3" .gitattributes 2>/dev/null; then
35
+ git lfs track "*.sqlite3"
36
+ git add .gitattributes
37
+ git commit -m "Track *.sqlite3 files with Git LFS" || echo "No changes to commit"
38
+ fi
39
+
40
+ # Stage and commit any uncommitted large files
41
+ - name: Commit large files
42
+ run: |
43
+ git add "*.sqlite3"
44
+ git commit -m "Sync large files to Hugging Face" || echo "No changes to commit"
45
+
46
+ # Push to Hugging Face Hub
47
+ - name: Push to Hub
48
  env:
49
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
50
  run: |
51
+ git remote set-url origin https://Oxbridge-Economics:[email protected]/spaces/Oxbridge-Economics/Mailbox
52
+ git push origin main