Spaces:
Sleeping
Sleeping
Update update_spaces.yaml
Browse files
.github/workflows/update_spaces.yaml
CHANGED
@@ -1,46 +1,35 @@
|
|
1 |
name: Update Spaces
|
2 |
|
3 |
on:
|
4 |
-
|
|
|
5 |
|
6 |
jobs:
|
7 |
-
|
8 |
runs-on: ubuntu-latest
|
|
|
|
|
|
|
9 |
steps:
|
10 |
-
-
|
11 |
-
|
12 |
-
fetch-depth: 0
|
13 |
-
lfs: true
|
14 |
|
15 |
-
|
16 |
-
|
|
|
|
|
|
|
|
|
17 |
env:
|
18 |
HF_TOKEN: ${{ secrets.HF_TOKEN }}
|
19 |
run: |
|
20 |
-
git
|
21 |
-
git
|
22 |
-
|
23 |
-
# Check for changed files since last commit
|
24 |
-
changed_files=$(git diff --name-only HEAD^)
|
25 |
|
26 |
-
#
|
27 |
-
|
28 |
-
|
29 |
-
|
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 |
-
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|