Add Gitea PR automation script
- Create automation/gitea-pr.sh for auto-creating PRs via Gitea API - Update CLAUDE.md with git workflow using the new script - Deprecate redundant git instructions in PA general-instructions.json - Token stored securely at ~/.config/gitea-token Usage: gitea-pr.sh "PR Title" "Description" 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
61
automation/gitea-pr.sh
Executable file
61
automation/gitea-pr.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/bin/bash
|
||||
# Create a PR in Gitea for the current branch
|
||||
# Usage: gitea-pr.sh [title] [body]
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GITEA_URL="https://gitea-http.taildb3494.ts.net"
|
||||
REPO="will/claude-code"
|
||||
TOKEN_FILE="$HOME/.config/gitea-token"
|
||||
|
||||
if [[ ! -f "$TOKEN_FILE" ]]; then
|
||||
echo "Error: Gitea token not found at $TOKEN_FILE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TOKEN=$(cat "$TOKEN_FILE")
|
||||
|
||||
# Get current branch
|
||||
BRANCH=$(git rev-parse --abbrev-ref HEAD)
|
||||
|
||||
if [[ "$BRANCH" == "main" ]]; then
|
||||
echo "Error: Cannot create PR from main branch" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Default title from branch name
|
||||
TITLE="${1:-$BRANCH}"
|
||||
BODY="${2:-Auto-generated PR for $BRANCH}"
|
||||
|
||||
# Create PR via API
|
||||
RESPONSE=$(curl -s -X POST \
|
||||
-H "Authorization: token $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{
|
||||
\"title\": \"$TITLE\",
|
||||
\"body\": \"$BODY\",
|
||||
\"head\": \"$BRANCH\",
|
||||
\"base\": \"main\"
|
||||
}" \
|
||||
"$GITEA_URL/api/v1/repos/$REPO/pulls")
|
||||
|
||||
# Extract PR URL or error
|
||||
PR_URL=$(echo "$RESPONSE" | python3 -c "
|
||||
import sys, json
|
||||
d = json.load(sys.stdin)
|
||||
if 'html_url' in d:
|
||||
print(d['html_url'])
|
||||
elif 'message' in d:
|
||||
print(f\"Error: {d['message']}\", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(f'Unexpected response: {d}', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
" 2>&1)
|
||||
|
||||
if [[ $? -eq 0 ]]; then
|
||||
echo "PR created: $PR_URL"
|
||||
else
|
||||
echo "$PR_URL" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user