#!/bin/bash # Gitea PR Creation Helper # Creates pull requests on git.manticorum.com via API # # Usage: # gitea-create-pr.sh [description] # # Example: # gitea-create-pr.sh cal/major-domo-database fix/my-feature main "Fix: My feature" "Description here" set -e # Check arguments if [ $# -lt 4 ]; then echo "Usage: $0 <owner/repo> <head-branch> <base-branch> <title> [description]" echo "" echo "Example:" echo " $0 cal/paper-dynasty fix/feature main 'Fix: Feature title' 'Optional description'" exit 1 fi REPO="$1" HEAD_BRANCH="$2" BASE_BRANCH="$3" TITLE="$4" DESCRIPTION="${5:-Automated PR created by Claude Code}" # Load token GITEA_TOKEN=$(cat /home/cal/.claude/secrets/gitea_token | tr -d '\n') if [ -z "$GITEA_TOKEN" ]; then echo "ERROR: Gitea token not found at /home/cal/.claude/secrets/gitea_token" exit 1 fi # Create PR via Gitea API echo "Creating PR on https://git.manticorum.com/$REPO" echo " Head: $HEAD_BRANCH" echo " Base: $BASE_BRANCH" echo " Title: $TITLE" echo "" RESPONSE=$(curl -s -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ "https://git.manticorum.com/api/v1/repos/$REPO/pulls" \ -d @- <<EOF { "title": "$TITLE", "head": "$HEAD_BRANCH", "base": "$BASE_BRANCH", "body": "$DESCRIPTION" } EOF ) # Check for errors if echo "$RESPONSE" | grep -q '"message"'; then echo "ERROR: Failed to create PR" echo "$RESPONSE" | jq -r '.message // .' exit 1 fi # Extract PR number and URL PR_NUMBER=$(echo "$RESPONSE" | jq -r '.number') PR_URL=$(echo "$RESPONSE" | jq -r '.html_url') echo "PR created successfully!" echo " Number: #$PR_NUMBER" echo " URL: $PR_URL" echo "" echo "Gitea Actions will now run on this PR."