| #!/usr/bin/env bash |
| |
| |
| |
| |
| |
| set -euo pipefail |
|
|
| : "${HF_USER:?Set HF_USER to your Hugging Face username, e.g. export HF_USER=foo}" |
| SPACE_NAME="opensoc-env" |
| SPACE_URL="https://huggingface.co/spaces/${HF_USER}/${SPACE_NAME}" |
|
|
| echo "Deploying to ${SPACE_URL}" |
|
|
| |
| huggingface-cli repo create "${SPACE_NAME}" --type space --space-sdk docker -y \ |
| || echo "(space already exists or create errored — continuing)" |
|
|
| |
| if ! git remote get-url space >/dev/null 2>&1; then |
| git remote add space "${SPACE_URL}" |
| else |
| git remote set-url space "${SPACE_URL}" |
| fi |
|
|
| |
| TMP_BRANCH="space-deploy-$(date +%s)" |
| git checkout -b "${TMP_BRANCH}" |
| cat SPACE_README.md > README.md.space |
| mv README.md README.md.bak |
| mv README.md.space README.md |
| git add README.md |
| git commit -m "Space metadata header (auto)" |
| git push -u space "${TMP_BRANCH}:main" |
| echo "" |
| echo "Pushed to ${SPACE_URL}. Restoring local README ..." |
| git reset --hard HEAD~1 |
| mv README.md.bak README.md 2>/dev/null || true |
| git checkout main |
| git branch -D "${TMP_BRANCH}" |
| echo "" |
| echo "Done. Open ${SPACE_URL%/spaces*}/spaces/${HF_USER}/${SPACE_NAME} to watch the build," |
| echo "then visit:" |
| echo " ${SPACE_URL%/spaces*}/${HF_USER}-${SPACE_NAME}.hf.space/health" |
| echo " ${SPACE_URL%/spaces*}/${HF_USER}-${SPACE_NAME}.hf.space/demo" |
|
|