Files
timmy-config/wizards/allegro/claw-code-gitea-setup.sh
2026-04-01 23:00:10 +00:00

64 lines
2.0 KiB
Bash

#!/bin/bash
# CLAW CODE GITEA SETUP SCRIPT
# Run this on the Gitea host (100.101.194.61) to create claw-code identity
set -e
GITEA_URL="http://localhost:3000"
ADMIN_TOKEN="${GITEA_ADMIN_TOKEN}" # Must be set
echo "=== CREATING CLAW-CODE GITEA IDENTITY ==="
# 1. Create claw-code user
echo "Creating user 'claw-code'..."
curl -s -X POST "${GITEA_URL}/api/v1/admin/users" \
-H "Authorization: token ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"username": "claw-code",
"email": "claw-code@timmy.local",
"password": "'$(openssl rand -base64 32)'",
"full_name": "Claw Code Harness",
"must_change_password": false
}' | tee /tmp/claw-code-user.json
echo ""
# 2. Generate API token for claw-code
echo "Generating API token..."
curl -s -X POST "${GITEA_URL}/api/v1/users/claw-code/tokens" \
-H "Authorization: token ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "harness-automation",
"scopes": ["repo", "issue", "pull_request", "webhook"]
}' | tee /tmp/claw-code-token.json
echo ""
# 3. Add claw-code to timmy-time org
echo "Adding to timmy-time organization..."
curl -s -X PUT "${GITEA_URL}/api/v1/orgs/timmy-time/members/claw-code" \
-H "Authorization: token ${ADMIN_TOKEN}" \
-d '{"role": "write"}'
echo "Added claw-code to timmy-time org with write access"
# 4. Create webhook for auto-dispatch
echo "Creating webhook for auto-dispatch..."
curl -s -X POST "${GITEA_URL}/api/v1/repos/timmy-time/timmy/hooks" \
-H "Authorization: token ${ADMIN_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"type": "gitea",
"config": {
"url": "http://167.99.126.228:8646/webhook/gitea",
"content_type": "json",
"secret": "'$(openssl rand -hex 32)'"
},
"events": ["issues", "issue_comment", "pull_request", "pull_request_comment", "label"],
"active": true
}' | tee /tmp/claw-code-webhook.json
echo ""
echo "=== SETUP COMPLETE ==="
echo "Save the token from /tmp/claw-code-token.json securely"
echo "Configure Allegro VM with CLAW_CODE_GITEA_TOKEN"