soiz1 commited on
Commit
c92ce3d
·
verified ·
1 Parent(s): 6c27beb

Update upload.sh

Browse files
Files changed (1) hide show
  1. upload.sh +10 -20
upload.sh CHANGED
@@ -1,32 +1,22 @@
1
  #!/bin/bash
2
-
3
- # Exit on error
4
  set -e
5
 
6
- # Check if the token is set
7
  if [ -z "$sc4sc_token" ]; then
8
  echo "Error: Environment variable sc4sc_token is not set."
9
  exit 1
10
  fi
11
 
12
- # Define variables
13
  SPACE_REPO="sc4sc/editor"
14
- API_URL="https://huggingface.co/api/spaces/$SPACE_REPO"
15
- TEMP_DIR=$(mktemp -d)
16
- ZIP_FILE="$TEMP_DIR/upload.zip"
17
-
18
- # Create zip of all files and folders in current directory
19
- zip -r "$ZIP_FILE" . -x "*.git*" -x "$ZIP_FILE"
20
 
21
- # Upload to the space
22
- echo "Uploading to Hugging Face Space: $SPACE_REPO"
23
-
24
- curl -X POST "$API_URL/upload" \
25
- -H "Authorization: Bearer $sc4sc_token" \
26
- -H "Content-Type: application/zip" \
27
- --data-binary @"$ZIP_FILE"
28
 
29
- # Clean up
30
- rm -rf "$TEMP_DIR"
 
31
 
32
- echo "✅ Upload completed successfully."
 
1
  #!/bin/bash
 
 
2
  set -e
3
 
 
4
  if [ -z "$sc4sc_token" ]; then
5
  echo "Error: Environment variable sc4sc_token is not set."
6
  exit 1
7
  fi
8
 
 
9
  SPACE_REPO="sc4sc/editor"
10
+ GIT_URL="https://hf_$sc4sc_token@huggingface.co/spaces/$SPACE_REPO"
 
 
 
 
 
11
 
12
+ # Initialize repo if not already
13
+ if [ ! -d ".git" ]; then
14
+ git init
15
+ git remote add origin "$GIT_URL"
16
+ fi
 
 
17
 
18
+ git add .
19
+ git commit -m "Automated update" || echo "Nothing to commit"
20
+ git push origin main
21
 
22
+ echo "✅ Space successfully updated."