CuriousLearner / scripts /setup_hf_secret.sh
afmjoaa
Update firebase credential, use from hf space secret
9128c01
#!/bin/bash
# Script to set up Firebase credentials secret on Hugging Face Spaces
# Usage: ./scripts/setup_hf_secret.sh
set -e
SPACE_NAME="MCP-1st-Birthday/CuriousLearner"
SECRET_NAME="FIREBASE_CREDENTIALS_JSON"
CREDENTIALS_FILE="firebase-credentials.json"
echo "πŸ”§ Setting up Firebase credentials secret on HF Spaces..."
# Check if huggingface-cli is installed
if ! command -v huggingface-cli &> /dev/null; then
echo "❌ Error: huggingface-cli not found!"
echo "Please install it: pip install huggingface-hub[cli]"
exit 1
fi
# Check if credentials file exists
if [ ! -f "$CREDENTIALS_FILE" ]; then
echo "❌ Error: $CREDENTIALS_FILE not found!"
echo "Please ensure the credentials file exists in the current directory."
exit 1
fi
# Check if user is logged in
if ! huggingface-cli whoami &> /dev/null; then
echo "❌ Error: Not logged in to Hugging Face!"
echo "Please run: huggingface-cli login"
exit 1
fi
# Read credentials file and set as secret
echo "πŸ“€ Uploading secret to $SPACE_NAME..."
CREDENTIALS_CONTENT=$(cat "$CREDENTIALS_FILE")
# Use huggingface-cli to add secret
huggingface-cli repo secret set "$SECRET_NAME" \
--repo "$SPACE_NAME" \
--repo-type space \
--value "$CREDENTIALS_CONTENT"
echo "βœ… Secret $SECRET_NAME successfully set on $SPACE_NAME!"
echo "πŸš€ Your HF Space will now have access to Firebase credentials."
echo ""
echo "⚠️ Note: You may need to restart the Space for changes to take effect."