s4s-editor-beta / upload.sh
soiz1's picture
Update upload.sh
f326774 verified
raw
history blame
1.28 kB
#!/bin/bash
# 必須: 環境変数 sc4sc_token が設定されていることを確認
if [ -z "$sc4sc_token" ]; then
echo "Error: 環境変数 sc4sc_token が設定されていません。"
exit 1
fi
SRC_DIR=$(pwd)
git lfs install
# LFS対象ファイルを指定
git lfs track "js/scratch-gui.js"
git lfs track "js/scratch-gui.js.map"
# .gitattributes をコミット対象に追加(重要)
git add .gitattributes
WORK_DIR=$(mktemp -d)
echo "作業ディレクトリ: $WORK_DIR"
REPO_URL="https://user:$sc4sc_token@huggingface.co/spaces/s-4-s/editor"
git clone "$REPO_URL" "$WORK_DIR"
cd "$WORK_DIR" || exit 1
# クリーンアップ
find . -mindepth 1 -maxdepth 1 ! -name ".git" -exec rm -rf {} +
# dist ディレクトリの中身をコピー
rsync -av "$SRC_DIR/dist/" ./
# .gitattributes をコピー(必須)
cp "$SRC_DIR/.gitattributes" ./
# CMD を修正
if [ -f Dockerfile ]; then
sed -i.bak 's|CMD /bin/sh -c "./upload.sh && npm start"|CMD /bin/sh -c "npm start"|' Dockerfile
fi
git config user.name "auto-deploy"
git config user.email "[email protected]"
git add .
git commit -m "Auto deploy at $(date '+%Y-%m-%d %H:%M:%S')" || echo "No changes to commit."
git push origin main
cd ..
rm -rf "$WORK_DIR"
echo "アップロード完了 ✅"