mmrech commited on
Commit
3c0e60a
Β·
1 Parent(s): 447a559

Add GitHub Actions workflow and setup script for GitHub-Hugging Face sync

Browse files
.github/workflows/sync-to-hf.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Sync to Hugging Face Space
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ workflow_dispatch: # Allow manual triggering
8
+
9
+ jobs:
10
+ sync-to-hf:
11
+ runs-on: ubuntu-latest
12
+ steps:
13
+ - name: Checkout repository
14
+ uses: actions/checkout@v4
15
+ with:
16
+ fetch-depth: 0
17
+ lfs: true
18
+
19
+ - name: Setup Git
20
+ run: |
21
+ git config --global user.name "GitHub Actions"
22
+ git config --global user.email "actions@github.com"
23
+
24
+ - name: Add Hugging Face remote
25
+ run: |
26
+ git remote add hf https://huggingface.co/spaces/mmrech/NeuroSAM3 || true
27
+ git remote set-url hf https://huggingface.co/spaces/mmrech/NeuroSAM3
28
+
29
+ - name: Push to Hugging Face Space
30
+ env:
31
+ HF_TOKEN: ${{ secrets.HF_TOKEN }}
32
+ run: |
33
+ git push https://oauth2:${HF_TOKEN}@huggingface.co/spaces/mmrech/NeuroSAM3 main || \
34
+ git push hf main
35
+
.gitignore CHANGED
@@ -41,3 +41,6 @@ Thumbs.db
41
  # Demo files (optional - uncomment if you don't want demo files in repo)
42
  # demo_brain_mri.dcm
43
 
 
 
 
 
41
  # Demo files (optional - uncomment if you don't want demo files in repo)
42
  # demo_brain_mri.dcm
43
 
44
+ # Setup scripts (keep these)
45
+ !setup_github_sync.sh
46
+
setup_github_sync.sh ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Setup script to add GitHub remote and configure dual-push
3
+
4
+ set -e
5
+
6
+ echo "πŸ”— Setting up GitHub remote and dual-push configuration..."
7
+ echo ""
8
+
9
+ # Check if GitHub URL is provided
10
+ if [ -z "$1" ]; then
11
+ echo "Usage: ./setup_github_sync.sh <github_repo_url>"
12
+ echo "Example: ./setup_github_sync.sh https://github.com/username/NeuroSAM3.git"
13
+ exit 1
14
+ fi
15
+
16
+ GITHUB_URL=$1
17
+
18
+ # Add GitHub remote
19
+ echo "πŸ“¦ Adding GitHub remote..."
20
+ git remote add github "$GITHUB_URL" 2>/dev/null || git remote set-url github "$GITHUB_URL"
21
+ echo "βœ… GitHub remote added: $GITHUB_URL"
22
+
23
+ # Show current remotes
24
+ echo ""
25
+ echo "πŸ“‹ Current remotes:"
26
+ git remote -v
27
+
28
+ # Create git hook for automatic dual-push (optional)
29
+ echo ""
30
+ echo "πŸ’‘ To push to both remotes automatically, use:"
31
+ echo " git push origin main && git push github main"
32
+ echo ""
33
+ echo " Or set up an alias:"
34
+ echo " git config alias.pushall '!git push origin main && git push github main'"
35
+ echo " Then use: git pushall"
36
+ echo ""
37
+ echo "βœ… Setup complete!"
38
+ echo ""
39
+ echo "πŸ“ Next steps:"
40
+ echo " 1. Push to GitHub: git push github main"
41
+ echo " 2. Set up GitHub Actions secret:"
42
+ echo " - Go to: https://github.com/YOUR_USERNAME/NeuroSAM3/settings/secrets/actions"
43
+ echo " - Add secret: HF_TOKEN = your_huggingface_token"
44
+ echo " 3. GitHub Actions will automatically sync to Hugging Face on every push"
45
+