Add GITEA_API_TOKEN to deployment API for private repo access

SAAC API now receives user's GITEA_API_TOKEN to enable Coolify to clone private repositories.

Changes:
- Added early validation of GITEA_API_TOKEN (before app creation)
- Pass git_token parameter to SAAC API in application creation request
- Removed duplicate GITEA_API_TOKEN check in webhook section
- Updated error message to explain both use cases (cloning + webhooks)

The SAAC API will use this token to configure Coolify with authenticated git access:
https://${GITEA_API_TOKEN}@git.startanaicompany.com/${user}/${repo}.git

This enables automatic deployments for private repositories.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-01-24 08:59:10 +01:00
parent 09c198490d
commit bcc07b33fc

View File

@@ -40,6 +40,22 @@ if [ -z "$SAAC_API_KEY" ]; then
exit 1
fi
if [ -z "$GITEA_API_TOKEN" ]; then
echo "❌ Error: GITEA_API_TOKEN environment variable not set"
echo ""
echo "GITEA_API_TOKEN is required for:"
echo " - Cloning your private repository"
echo " - Setting up automatic deployment 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
# Check required .env variables
if [ -z "$COMPANY_NAME" ]; then
echo "❌ Error: COMPANY_NAME not set in .env"
@@ -90,6 +106,7 @@ APP_RESPONSE=$(curl -s -X POST "${SAAC_API}/applications" \
\"domain_suffix\": \"recruit.startanaicompany.com\",
\"git_repository\": \"${REPO_URL}\",
\"git_branch\": \"master\",
\"git_token\": \"${GITEA_API_TOKEN}\",
\"template_type\": \"recruitment\",
\"environment_variables\": {
\"COMPANY_NAME\": \"${COMPANY_NAME}\",
@@ -130,20 +147,6 @@ echo ""
# Configure webhook for automatic deployments
echo "🪝 Setting up deployment webhook..."
if [ -z "$GITEA_API_TOKEN" ]; then
echo "❌ Error: GITEA_API_TOKEN environment variable not set"
echo ""
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" \