Spaces:
Runtime error
Runtime error
| set -euo pipefail | |
| # Simple deploy helper to push the current repo to a Hugging Face Space. | |
| # Usage: | |
| # HF_USER=athulnambiar HF_SPACE=pyqsprag HF_TOKEN=hf_xxx ./scripts/push_to_hf.sh | |
| # Optional: | |
| # BRANCH=main QDRYRUN=1 | |
| HF_USER=${HF_USER:-} | |
| HF_SPACE=${HF_SPACE:-} | |
| HF_TOKEN=${HF_TOKEN:-} | |
| BRANCH=${BRANCH:-main} | |
| if [[ -z "${HF_USER}" || -z "${HF_SPACE}" || -z "${HF_TOKEN}" ]]; then | |
| echo "ERROR: Please set HF_USER, HF_SPACE, and HF_TOKEN environment variables." >&2 | |
| echo "Example: HF_USER=athulnambiar HF_SPACE=pyqsprag HF_TOKEN=hf_*** ./scripts/push_to_hf.sh" >&2 | |
| exit 1 | |
| fi | |
| repo_url="https://${HF_USER}:${HF_TOKEN}@huggingface.co/spaces/${HF_USER}/${HF_SPACE}" | |
| workdir=$(mktemp -d) | |
| echo "Cloning Space into: ${workdir}" >&2 | |
| git clone "${repo_url}" "${workdir}/space" | |
| # Ensure branch exists and is checked out | |
| pushd "${workdir}/space" >/dev/null | |
| git checkout -B "${BRANCH}" | |
| popd >/dev/null | |
| # Sync files from current repo into the Space, excluding local/dev artifacts | |
| rsync -av --delete \ | |
| --exclude ".git" \ | |
| --exclude ".venv" \ | |
| --exclude "__pycache__/" \ | |
| --exclude "qdrant_storage/" \ | |
| --exclude "uploads/" \ | |
| --exclude ".env" \ | |
| --exclude ".claude/" \ | |
| --exclude ".streamlit/secrets.toml" \ | |
| ./ "${workdir}/space/" | |
| pushd "${workdir}/space" >/dev/null | |
| # Make sure Streamlit apps deploy on Spaces | |
| if [[ ! -f requirements.txt ]]; then | |
| echo "streamlit>=1.28.0" > requirements.txt | |
| fi | |
| # Commit and push | |
| git add -A | |
| if git diff --cached --quiet; then | |
| echo "No changes to push." | |
| else | |
| git commit -m "Deploy from QUADRANT_RAG" | |
| if [[ "${QDRYRUN:-}" == "1" ]]; then | |
| echo "Dry run enabled; skipping push." >&2 | |
| else | |
| git push -u origin "${BRANCH}" | |
| fi | |
| fi | |
| echo "Deploy complete. Space: https://huggingface.co/spaces/${HF_USER}/${HF_SPACE}" >&2 | |