Jayant2304/commitment-os
0
1#!/usr/bin/env bash2# Sync this repo into the Hugging Face Space (same pattern as incident_response_env/deploy.sh).3# HF rejects binary PNGs on git push — we rsync the tree omitting *.png; training curves stay on GitHub.4set -euo pipefail5 6HF_USERNAME="${HF_USERNAME:-Jayant2304}"7SPACE_NAME="${SPACE_NAME:-commitment-os}"8HF_TOKEN="${HF_TOKEN:?Set HF_TOKEN for git push to Hugging Face (see https://huggingface.co/settings/tokens)}"9COMMIT_MSG="${1:-Sync from GitHub (exclude *.png per HF policy)}"10 11SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"12REPO_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"13CLONE_DIR="${HF_SYNC_CLONE_DIR:-/tmp/hf-sync-${SPACE_NAME}}"14 15echo "==> Cloning Space into ${CLONE_DIR}"16rm -rf "${CLONE_DIR}"17git clone "https://${HF_USERNAME}:${HF_TOKEN}@huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}" "${CLONE_DIR}"18 19echo "==> Rsync from ${REPO_ROOT} (excluding PNGs and local-only paths)"20rsync -a --delete \21 --exclude '.git/' \22 --exclude '.venv/' \23 --exclude 'venv/' \24 --exclude '__pycache__/' \25 --exclude '.pytest_cache/' \26 --exclude '.ruff_cache/' \27 --exclude '*.egg-info/' \28 --exclude '.env' \29 --exclude 'training_output/' \30 --exclude '*.png' \31 --exclude '.DS_Store' \32 "${REPO_ROOT}/" "${CLONE_DIR}/"33 34echo "==> Space README: HF_README.md -> README.md"35cp "${REPO_ROOT}/HF_README.md" "${CLONE_DIR}/README.md"36 37cd "${CLONE_DIR}"38git add -A39if git diff --cached --quiet; then40 echo "==> No changes to commit (tree already matched)"41else42 git commit -m "${COMMIT_MSG}"43fi44 45echo "==> Pushing to Hugging Face"46git push47 48echo "==> Done. Build: https://huggingface.co/spaces/${HF_USERNAME}/${SPACE_NAME}"49 