Spaces:
Sleeping
Sleeping
| # Create HF Space FocusGuard/test_final (Docker) and push hugging_face_final -> main. | |
| # Usage (in your terminal only — do not commit tokens): | |
| # export HF_TOKEN="hf_..." | |
| # ./scripts/push_hf_test_final.sh | |
| # | |
| # First push after HF creates the Space: remote `main` may have an initial README | |
| # commit — we use --force so your branch replaces it. Set HF_PUSH_FORCE=0 to refuse | |
| # overwriting if the remote already has your history. | |
| set -euo pipefail | |
| : "${HF_TOKEN:?Set HF_TOKEN (Hugging Face access token with write access)}" | |
| ORG="FocusGuard" | |
| SPACE="test_final" | |
| REPO_ID="${ORG}/${SPACE}" | |
| BRANCH="hugging_face_final" | |
| ROOT="$(cd "$(dirname "$0")/.." && pwd)" | |
| cd "$ROOT" | |
| python3 -m pip install -q 'huggingface_hub>=0.20' | |
| python3 -c " | |
| from huggingface_hub import HfApi | |
| import os | |
| api = HfApi(token=os.environ['HF_TOKEN']) | |
| api.create_repo( | |
| repo_id='${REPO_ID}', | |
| repo_type='space', | |
| space_sdk='docker', | |
| exist_ok=True, | |
| ) | |
| print('Space ${REPO_ID}: OK') | |
| " | |
| command -v git-lfs >/dev/null 2>&1 && git lfs install >/dev/null || true | |
| URL="https://oauth2:${HF_TOKEN}@huggingface.co/spaces/${REPO_ID}.git" | |
| FORCE=(--force) | |
| if [[ "${HF_PUSH_FORCE:-1}" == "0" ]]; then | |
| FORCE=() | |
| fi | |
| git push "${FORCE[@]}" "${URL}" "${BRANCH}:main" | |
| echo "Done. Open: https://huggingface.co/spaces/${REPO_ID}" | |