Skip to content

Commit 5465a66

Browse files
authored
[PM-28104] - Implement our check-run action instead of manually blocking bots (#482)
* Implement our check-run action instead of manually blocking bots * Self-reference the check-run & quote the `$GITHUB_OUTPUT` trusted variable
1 parent 94f093e commit 5465a66

2 files changed

Lines changed: 25 additions & 26 deletions

File tree

.github/workflows/_respond.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,15 @@ on:
1313
permissions: {}
1414

1515
jobs:
16+
check-run:
17+
name: Check PR run
18+
uses: ./.github/workflows/check-run.yml
19+
permissions:
20+
contents: read
21+
1622
validation:
1723
name: Validation
24+
needs: check-run
1825
runs-on: ubuntu-24.04
1926
permissions:
2027
contents: read
@@ -44,10 +51,10 @@ jobs:
4451
fi
4552
4653
if [ "$MENTIONED" == "true" ]; then
47-
echo "claude_mentioned=true" >> $GITHUB_OUTPUT
54+
echo "claude_mentioned=true" >> "$GITHUB_OUTPUT"
4855
echo "✅ Validation: @claude mentioned in event"
4956
else
50-
echo "claude_mentioned=false" >> $GITHUB_OUTPUT
57+
echo "claude_mentioned=false" >> "$GITHUB_OUTPUT"
5158
echo "⏭️ Validation: @claude not mentioned - skipping"
5259
fi
5360
@@ -57,10 +64,10 @@ jobs:
5764
CLAUDE_MENTIONED: ${{ steps.check-github-event.outputs.claude_mentioned }}
5865
run: |
5966
if [ "$CLAUDE_MENTIONED" == "true" ] ; then
60-
echo "should_comment=true" >> $GITHUB_OUTPUT
67+
echo "should_comment=true" >> "$GITHUB_OUTPUT"
6168
echo "✅ Validation passed - comment will proceed"
6269
else
63-
echo "should_comment=false" >> $GITHUB_OUTPUT
70+
echo "should_comment=false" >> "$GITHUB_OUTPUT"
6471
echo "⚠️ Validation failed - comment will be skipped"
6572
fi
6673

.github/workflows/_review-code.yml

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,15 @@ concurrency:
1717
permissions: {}
1818

1919
jobs:
20+
check-run:
21+
name: Check PR run
22+
uses: ./.github/workflows/check-run.yml
23+
permissions:
24+
contents: read
25+
2026
validation:
2127
name: Validation
28+
needs: check-run
2229
runs-on: ubuntu-24.04
2330
permissions:
2431
contents: read
@@ -33,23 +40,10 @@ jobs:
3340
run: |
3441
if [ "$IS_DRAFT" == "true" ]; then
3542
echo "⚠️ Validation: PR is a draft - skipping review"
36-
echo "pr_valid=false" >> $GITHUB_OUTPUT
43+
echo "pr_valid=false" >> "$GITHUB_OUTPUT"
3744
else
3845
echo "✅ Validation: PR is ready for review"
39-
echo "pr_valid=true" >> $GITHUB_OUTPUT
40-
fi
41-
42-
- name: Check if PR is from a bot
43-
id: check-user-type-bot
44-
env:
45-
PR_AUTHOR_TYPE: ${{ github.event.pull_request.user.type }}
46-
run: |
47-
if [ "$PR_AUTHOR_TYPE" == "Bot" ]; then
48-
echo "⚠️ Validation: PR opened by bot - skipping review"
49-
echo "is_bot=true" >> $GITHUB_OUTPUT
50-
else
51-
echo "✅ Validation: PR opened by human user"
52-
echo "is_bot=false" >> $GITHUB_OUTPUT
46+
echo "pr_valid=true" >> "$GITHUB_OUTPUT"
5347
fi
5448
5549
- name: Check if prompt file exists using GitHub CLI
@@ -61,10 +55,10 @@ jobs:
6155
FILE_PATH: ".claude/prompts/review-code.md"
6256
run: |
6357
if gh api "repos/$REPO/contents/$FILE_PATH?ref=$REF" --silent 2>/dev/null; then
64-
echo "prompt_exists=true" >> $GITHUB_OUTPUT
58+
echo "prompt_exists=true" >> "$GITHUB_OUTPUT"
6559
echo "✅ Found $FILE_PATH in $REPO"
6660
else
67-
echo "prompt_exists=false" >> $GITHUB_OUTPUT
61+
echo "prompt_exists=false" >> "$GITHUB_OUTPUT"
6862
echo "⚠️ Validation: No $FILE_PATH found - skipping Claude review"
6963
fi
7064
@@ -73,15 +67,13 @@ jobs:
7367
env:
7468
PR_VALID: ${{ steps.check-pr.outputs.pr_valid }}
7569
PROMPT_EXISTS: ${{ steps.check-prompt.outputs.prompt_exists }}
76-
IS_BOT: ${{ steps.check-user-type-bot.outputs.is_bot }}
7770
run: |
7871
if [ "$PR_VALID" == "true" ] && \
79-
[ "$PROMPT_EXISTS" == "true" ] && \
80-
[ "$IS_BOT" == "false" ]; then
81-
echo "should_review=true" >> $GITHUB_OUTPUT
72+
[ "$PROMPT_EXISTS" == "true" ]; then
73+
echo "should_review=true" >> "$GITHUB_OUTPUT"
8274
echo "✅ Validation passed - code review will proceed"
8375
else
84-
echo "should_review=false" >> $GITHUB_OUTPUT
76+
echo "should_review=false" >> "$GITHUB_OUTPUT"
8577
echo "⚠️ Validation failed - code review will be skipped"
8678
fi
8779

0 commit comments

Comments
 (0)