#!/bin/bash set -e cd "$(dirname "$0")" echo "=== AirMicroDrip HF Space Deployment ===" # Configuration SPACE_ID="${HF_SPACE_ID:-josephrw/membra-airmicrodrip}" TOKEN="${HF_TOKEN:-${HUGGINGFACE_TOKEN:-${HUGGING_FACE_TOKEN:-}}}" if [ -z "$TOKEN" ]; then echo "ERROR: Set HF_TOKEN environment variable" exit 1 fi echo "Space: $SPACE_ID" # Initialize git if needed if [ ! -d .git ]; then git init git config user.email "deploy@membra.ai" git config user.name "MEMBRA Deploy" fi # Add remote if needed if ! git remote | grep -q origin; then git remote add origin "https://huggingface.co/spaces/$SPACE_ID" fi # Stage all files git add -A # Commit git commit -m "Deploy AirMicroDrip - no mocks, real APIs" || echo "Nothing new to commit" # Push using token for auth (HF uses token as password with dummy username) echo "Pushing to Hugging Face..." git remote set-url origin "https://huggingface.co/spaces/$SPACE_ID" askpass_file="$(mktemp)" cat > "$askpass_file" <<'ASKPASS' #!/bin/sh case "$1" in *Username*) printf '%s\n' "user" ;; *Password*) printf '%s\n' "$HF_TOKEN" ;; *) printf '\n' ;; esac ASKPASS chmod 700 "$askpass_file" trap 'rm -f "$askpass_file"' EXIT if ! GIT_ASKPASS="$askpass_file" git push origin main --force 2>&1; then echo "" echo "ERROR: Git push failed. Possible causes:" echo " 1. Token is invalid or expired" echo " 2. Token lacks 'write' permission for Spaces" echo " 3. Space does not exist and token cannot create Spaces" exit 1 fi echo "" echo "=== Deployed ===" echo "Space: https://huggingface.co/spaces/$SPACE_ID" echo "" echo "Set environment variables in Space Settings:" echo " TOKEN_MINT=" echo " INFERENCE_API_URL=" echo " SOLANA_RPC_URL=https://api.devnet.solana.com"