Make GITEA_API_TOKEN required for automatic deployments
Automatic deployments are essential for the template, so GITEA_API_TOKEN is now required. Changes: - .env.example: Marked both API keys as REQUIRED - deploy-to-apps.example.sh: Script now exits with error if GITEA_API_TOKEN not set - Added clear instructions on how to get Gitea API token Without webhooks, users would need to manually trigger deployments after every push, which defeats the purpose of automated infrastructure. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -65,10 +65,10 @@ DB_PASSWORD=
|
|||||||
# ===================================
|
# ===================================
|
||||||
# API Tokens (for deployment script)
|
# API Tokens (for deployment script)
|
||||||
# ===================================
|
# ===================================
|
||||||
# Get your SAAC_API_KEY from: https://apps.startanaicompany.com/api/v1/register
|
# REQUIRED: Get your SAAC_API_KEY from: https://apps.startanaicompany.com/api/v1/register
|
||||||
# Set as environment variable: export SAAC_API_KEY="your_key_here"
|
# Set as environment variable: export SAAC_API_KEY="your_key_here"
|
||||||
#
|
#
|
||||||
# GITEA_API_TOKEN is optional - only needed for automatic webhook setup
|
# REQUIRED: GITEA_API_TOKEN needed for automatic deployments (webhook setup)
|
||||||
# Get from: https://git.startanaicompany.com → Settings → Applications → Generate New Token
|
# Get from: https://git.startanaicompany.com → Settings → Applications → Generate New Token
|
||||||
# Set as environment variable: export GITEA_API_TOKEN="your_token_here"
|
# Set as environment variable: export GITEA_API_TOKEN="your_token_here"
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
# Prerequisites:
|
# Prerequisites:
|
||||||
# 1. Register for API key at: https://apps.startanaicompany.com/api/v1/register
|
# 1. Register for API key at: https://apps.startanaicompany.com/api/v1/register
|
||||||
# 2. Set SAAC_API_KEY environment variable
|
# 2. Set SAAC_API_KEY environment variable
|
||||||
# 3. Set GITEA_API_TOKEN environment variable (optional, for webhooks)
|
# 3. Set GITEA_API_TOKEN environment variable (required for automatic deployments)
|
||||||
# 4. Customize your .env file with company information
|
# 4. Customize your .env file with company information
|
||||||
|
|
||||||
set -e # Exit on error
|
set -e # Exit on error
|
||||||
@@ -131,34 +131,42 @@ echo ""
|
|||||||
echo "🪝 Setting up deployment webhook..."
|
echo "🪝 Setting up deployment webhook..."
|
||||||
|
|
||||||
if [ -z "$GITEA_API_TOKEN" ]; then
|
if [ -z "$GITEA_API_TOKEN" ]; then
|
||||||
echo "⚠️ Warning: GITEA_API_TOKEN not set"
|
echo "❌ Error: GITEA_API_TOKEN environment variable not set"
|
||||||
echo " Skipping webhook setup. You can configure it manually later."
|
echo ""
|
||||||
echo " Webhook URL: $WEBHOOK_URL"
|
echo "Automatic deployments require GITEA_API_TOKEN to set up webhooks."
|
||||||
|
echo ""
|
||||||
|
echo "To get your Gitea API token:"
|
||||||
|
echo "1. Go to https://git.startanaicompany.com"
|
||||||
|
echo "2. Click your profile → Settings → Applications"
|
||||||
|
echo "3. Generate New Token (grant 'repo' permissions)"
|
||||||
|
echo "4. Export it: export GITEA_API_TOKEN='your_token_here'"
|
||||||
|
echo ""
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Create webhook in Gitea
|
||||||
|
GITEA_API="https://git.startanaicompany.com/api/v1"
|
||||||
|
WEBHOOK_RESPONSE=$(curl -s -X POST "${GITEA_API}/repos/${GITEA_USERNAME}/${GITEA_REPO_NAME}/hooks" \
|
||||||
|
-H "Authorization: token ${GITEA_API_TOKEN}" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "{
|
||||||
|
\"type\": \"gitea\",
|
||||||
|
\"config\": {
|
||||||
|
\"url\": \"${WEBHOOK_URL}\",
|
||||||
|
\"content_type\": \"json\",
|
||||||
|
\"http_method\": \"GET\"
|
||||||
|
},
|
||||||
|
\"events\": [\"push\"],
|
||||||
|
\"authorization_header\": \"Bearer ${SAAC_API_KEY}\",
|
||||||
|
\"active\": true
|
||||||
|
}")
|
||||||
|
|
||||||
|
WEBHOOK_ID=$(echo "$WEBHOOK_RESPONSE" | jq -r '.id' 2>/dev/null)
|
||||||
|
|
||||||
|
if [ "$WEBHOOK_ID" == "null" ] || [ -z "$WEBHOOK_ID" ]; then
|
||||||
|
echo "⚠️ Warning: Failed to create Gitea webhook (may already exist)"
|
||||||
else
|
else
|
||||||
# Create webhook in Gitea
|
echo "✅ Webhook configured for automatic deployments"
|
||||||
GITEA_API="https://git.startanaicompany.com/api/v1"
|
|
||||||
WEBHOOK_RESPONSE=$(curl -s -X POST "${GITEA_API}/repos/${GITEA_USERNAME}/${GITEA_REPO_NAME}/hooks" \
|
|
||||||
-H "Authorization: token ${GITEA_API_TOKEN}" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{
|
|
||||||
\"type\": \"gitea\",
|
|
||||||
\"config\": {
|
|
||||||
\"url\": \"${WEBHOOK_URL}\",
|
|
||||||
\"content_type\": \"json\",
|
|
||||||
\"http_method\": \"GET\"
|
|
||||||
},
|
|
||||||
\"events\": [\"push\"],
|
|
||||||
\"authorization_header\": \"Bearer ${SAAC_API_KEY}\",
|
|
||||||
\"active\": true
|
|
||||||
}")
|
|
||||||
|
|
||||||
WEBHOOK_ID=$(echo "$WEBHOOK_RESPONSE" | jq -r '.id' 2>/dev/null)
|
|
||||||
|
|
||||||
if [ "$WEBHOOK_ID" == "null" ] || [ -z "$WEBHOOK_ID" ]; then
|
|
||||||
echo "⚠️ Warning: Failed to create Gitea webhook (may already exist)"
|
|
||||||
else
|
|
||||||
echo "✅ Webhook configured for automatic deployments"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
|
|||||||
Reference in New Issue
Block a user