Skip to content

Commit 94ca5ea

Browse files
committed
Claude PR review workflow posts status checks
1 parent 72bec7b commit 94ca5ea

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

.github/workflows/claude-pr-review.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,22 @@ jobs:
119119
fi
120120
121121
echo "pr_head_ref=$(jq -r '.head.ref' /tmp/pr.json)" >> "$GITHUB_OUTPUT"
122+
echo "pr_head_sha=$(jq -r '.head.sha' /tmp/pr.json)" >> "$GITHUB_OUTPUT"
123+
124+
- name: Post pending status check
125+
env:
126+
GH_TOKEN: ${{ secrets.PHPSTAN_BOT_PR_TOKEN }}
127+
PR_HEAD_SHA: ${{ steps.review.outputs.pr_head_sha }}
128+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
129+
continue-on-error: true
130+
run: |
131+
gh api \
132+
--method POST \
133+
"repos/phpstan/phpstan-src/statuses/$PR_HEAD_SHA" \
134+
-f state=pending \
135+
-f context=phpstan-bot/review \
136+
-f description="Claude is addressing the review..." \
137+
-f target_url="$RUN_URL"
122138
123139
- name: "Checkout"
124140
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
@@ -357,6 +373,7 @@ jobs:
357373
run: npm install -g @anthropic-ai/claude-code
358374

359375
- name: Run Claude
376+
id: run-claude
360377
env:
361378
CLAUDE_CODE_OAUTH_TOKEN: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
362379
GH_TOKEN: ${{ secrets.PHPSTAN_BOT_FORK_TOKEN }}
@@ -393,3 +410,27 @@ jobs:
393410
|| gh pr comment "${{ inputs.pr_number }}" \
394411
--repo "phpstan/phpstan-src" \
395412
--body "$body"
413+
414+
- name: Post final status check
415+
if: always()
416+
env:
417+
GH_TOKEN: ${{ secrets.PHPSTAN_BOT_PR_TOKEN }}
418+
PR_HEAD_SHA: ${{ steps.review.outputs.pr_head_sha }}
419+
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
420+
CLAUDE_OUTCOME: ${{ steps.run-claude.outcome }}
421+
run: |
422+
if [ "$CLAUDE_OUTCOME" = "success" ]; then
423+
state=success
424+
description="Review addressed"
425+
else
426+
state=failure
427+
description="Failed to address review"
428+
fi
429+
430+
gh api \
431+
--method POST \
432+
"repos/phpstan/phpstan-src/statuses/$PR_HEAD_SHA" \
433+
-f state="$state" \
434+
-f context=phpstan-bot/review \
435+
-f description="$description" \
436+
-f target_url="$RUN_URL"

0 commit comments

Comments
 (0)