File size: 1,814 Bytes
b0e79f7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | #!/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=<your_solana_token_mint>"
echo " INFERENCE_API_URL=<your_llm_endpoint>"
echo " SOLANA_RPC_URL=https://api.devnet.solana.com"
|