Add debug output to workflow
This commit is contained in:
@@ -23,7 +23,14 @@ jobs:
|
|||||||
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
|
||||||
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
GIT_TOKEN: ${{ secrets.GIT_TOKEN }}
|
||||||
run: |
|
run: |
|
||||||
set -e
|
set -x
|
||||||
|
|
||||||
|
# Debug info
|
||||||
|
echo "Running as: $(whoami)"
|
||||||
|
echo "Home: $HOME"
|
||||||
|
echo "Claude version: $(claude --version 2>&1)"
|
||||||
|
echo "Working dir: $(pwd)"
|
||||||
|
ls -la
|
||||||
|
|
||||||
# Configure git
|
# Configure git
|
||||||
git config user.name "Claude Bot"
|
git config user.name "Claude Bot"
|
||||||
@@ -39,6 +46,9 @@ jobs:
|
|||||||
ISSUE_BODY=$(curl -s "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}" \
|
ISSUE_BODY=$(curl -s "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}" \
|
||||||
-H "Authorization: token ${GIT_TOKEN}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('body',''))")
|
-H "Authorization: token ${GIT_TOKEN}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('body',''))")
|
||||||
|
|
||||||
|
echo "Issue: #${ISSUE_NUMBER} - ${ISSUE_TITLE}"
|
||||||
|
echo "Body: ${ISSUE_BODY}"
|
||||||
|
|
||||||
# Get comment body if triggered by comment
|
# Get comment body if triggered by comment
|
||||||
COMMENT_BODY=""
|
COMMENT_BODY=""
|
||||||
if [ "${{ github.event_name }}" = "issue_comment" ]; then
|
if [ "${{ github.event_name }}" = "issue_comment" ]; then
|
||||||
@@ -57,13 +67,8 @@ jobs:
|
|||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"body\": \"Claude is working on this issue...\"}"
|
-d "{\"body\": \"Claude is working on this issue...\"}"
|
||||||
|
|
||||||
# Build the prompt
|
# Run Claude Code
|
||||||
PROMPT=$(cat <<'PROMPT_EOF'
|
CLAUDE_OUTPUT=$(claude -p "You are working on the repository ${REPO}.
|
||||||
You are working on a code repository. A Gitea issue needs your attention.
|
|
||||||
PROMPT_EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
PROMPT="You are working on the repository ${REPO}.
|
|
||||||
A Gitea issue needs your attention:
|
A Gitea issue needs your attention:
|
||||||
|
|
||||||
Issue #${ISSUE_NUMBER}: ${ISSUE_TITLE}
|
Issue #${ISSUE_NUMBER}: ${ISSUE_TITLE}
|
||||||
@@ -77,29 +82,31 @@ jobs:
|
|||||||
3. Make sure the code is correct and complete
|
3. Make sure the code is correct and complete
|
||||||
4. Commit all changes with a descriptive commit message
|
4. Commit all changes with a descriptive commit message
|
||||||
|
|
||||||
You are on branch ${BRANCH}. Work in the current directory."
|
You are on branch ${BRANCH}. Work in the current directory." \
|
||||||
|
|
||||||
# Run Claude Code in non-interactive mode
|
|
||||||
claude -p "${PROMPT}" \
|
|
||||||
--allowedTools "Bash,Read,Edit,Write,Glob,Grep" \
|
--allowedTools "Bash,Read,Edit,Write,Glob,Grep" \
|
||||||
--mcp-config /home/claude-runner/.claude/mcp-gitea.json \
|
--mcp-config /home/claude-runner/.claude/mcp-gitea.json \
|
||||||
--max-turns 50 \
|
--max-turns 50 \
|
||||||
--permission-mode bypassPermissions \
|
--permission-mode bypassPermissions \
|
||||||
--output-format text > /tmp/claude-output.txt 2>&1 || true
|
--output-format text 2>&1) || true
|
||||||
|
|
||||||
echo "=== Claude Output ==="
|
echo "=== CLAUDE OUTPUT START ==="
|
||||||
cat /tmp/claude-output.txt
|
echo "${CLAUDE_OUTPUT}"
|
||||||
echo "=== End Output ==="
|
echo "=== CLAUDE OUTPUT END ==="
|
||||||
|
|
||||||
|
# Also save to a persistent location for debugging
|
||||||
|
echo "${CLAUDE_OUTPUT}" > /home/claude-runner/last-claude-output.txt
|
||||||
|
|
||||||
# Stage any remaining unstaged changes
|
# Stage any remaining unstaged changes
|
||||||
git add -A
|
git add -A
|
||||||
|
|
||||||
# Check if there are changes
|
echo "=== GIT STATUS ==="
|
||||||
if ! git diff --cached --quiet 2>/dev/null || [ "$(git log origin/main..HEAD --oneline 2>/dev/null | wc -l)" -gt 0 ]; then
|
git status
|
||||||
# Commit if there are staged changes
|
echo "=== GIT DIFF ==="
|
||||||
git diff --cached --quiet 2>/dev/null || git commit -m "Claude: Address issue #${ISSUE_NUMBER} - ${ISSUE_TITLE}"
|
git diff --cached --stat
|
||||||
|
|
||||||
# Push
|
# Check if there are changes
|
||||||
|
if ! git diff --cached --quiet 2>/dev/null; then
|
||||||
|
git commit -m "Claude: Address issue #${ISSUE_NUMBER} - ${ISSUE_TITLE}"
|
||||||
git push origin "${BRANCH}"
|
git push origin "${BRANCH}"
|
||||||
|
|
||||||
# Create PR
|
# Create PR
|
||||||
@@ -113,14 +120,14 @@ jobs:
|
|||||||
\"base\": \"main\"
|
\"base\": \"main\"
|
||||||
}")
|
}")
|
||||||
|
|
||||||
PR_URL=$(echo "${PR_RESPONSE}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('html_url',''))" 2>/dev/null || echo "")
|
PR_URL=$(echo "${PR_RESPONSE}" | python3 -c "import sys,json; print(json.load(sys.stdin).get('html_url',''))" 2>/dev/null || echo "unknown")
|
||||||
|
|
||||||
# Comment with PR link
|
|
||||||
curl -s -X POST "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}/comments" \
|
curl -s -X POST "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}/comments" \
|
||||||
-H "Authorization: token ${GIT_TOKEN}" \
|
-H "Authorization: token ${GIT_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-d "{\"body\": \"Claude has created a pull request: ${PR_URL}\"}"
|
-d "{\"body\": \"Claude has created a pull request: ${PR_URL}\"}"
|
||||||
else
|
else
|
||||||
|
echo "No changes detected by Claude"
|
||||||
curl -s -X POST "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}/comments" \
|
curl -s -X POST "http://localhost:3000/api/v1/repos/${REPO}/issues/${ISSUE_NUMBER}/comments" \
|
||||||
-H "Authorization: token ${GIT_TOKEN}" \
|
-H "Authorization: token ${GIT_TOKEN}" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
|
|||||||
Reference in New Issue
Block a user