david-oplatka commited on
Commit
2fe6b48
·
unverified ·
1 Parent(s): cb8701b

Update update_spaces.yaml

Browse files
Files changed (1) hide show
  1. .github/workflows/update_spaces.yaml +21 -32
.github/workflows/update_spaces.yaml CHANGED
@@ -1,46 +1,35 @@
1
  name: Update Spaces
2
 
3
  on:
4
- workflow_dispatch:
 
5
 
6
  jobs:
7
- sync-to-hub:
8
  runs-on: ubuntu-latest
 
 
 
9
  steps:
10
- - uses: actions/checkout@v2
11
- with:
12
- fetch-depth: 0
13
- lfs: true
14
 
15
- # Perform specific actions for syncing files
16
- - name: Sync changed files to Hugging Face
 
 
 
 
17
  env:
18
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
19
  run: |
20
- git config user.email "actions@github.com"
21
- git config user.name "GitHub Actions"
22
-
23
- # Check for changed files since last commit
24
- changed_files=$(git diff --name-only HEAD^)
25
 
26
- # Iterate through changed files and stage them
27
- for file in $changed_files; do
28
- git add $file
29
- done
30
-
31
- # Commit changes if there are any
32
- if [[ -n "$changed_files" ]]; then
33
- git commit -m "Update changed files"
34
- git push --force origin main
35
- else
36
- echo "No changes detected."
37
  fi
38
 
39
- # List of Hugging Face Spaces (child repos)
40
- spaces=("company-pet-policy" "about-mls" "shakespeare")
41
-
42
- # Push changes to each Hugging Face Space
43
- for space_name in "${spaces[@]}"; do
44
- git remote add space "https://huggingface.co/spaces/${{ github.repository_owner }}/${space_name}.git"
45
- git push --force space main
46
- done
 
1
  name: Update Spaces
2
 
3
  on:
4
+ push:
5
+ branches: [ main ] # Update this to your branch name if different
6
 
7
  jobs:
8
+ update-spaces:
9
  runs-on: ubuntu-latest
10
+ strategy:
11
+ matrix:
12
+ space_name: [company-pet-policy, about-mls, shakespeare] # List your Hugging Face space names here
13
  steps:
14
+ - name: Checkout repository
15
+ uses: actions/checkout@v3
 
 
16
 
17
+ - name: Configure Git
18
+ run: |
19
+ git config --global user.email "[email protected]"
20
+ git config --global user.name "GitHub Actions"
21
+
22
+ - name: Update Space
23
  env:
24
  HF_TOKEN: ${{ secrets.HF_TOKEN }}
25
  run: |
26
+ git remote set-url origin https://david-oplatka:$HF_TOKEN@huggingface.co/spaces/david-oplatka/${{ matrix.space_name }}.git
27
+ git pull --rebase origin main # Pull with rebase to avoid merge conflicts
 
 
 
28
 
29
+ # Check for any unstaged changes (potential conflicts)
30
+ if [ $(git status --porcelain | grep '^##') ]; then
31
+ echo "Error: Unstaged changes detected in Space. Resolve conflicts and try again."
32
+ exit 1
 
 
 
 
 
 
 
33
  fi
34
 
35
+ git push origin main