Skip to content

Commit be38f10

Browse files
authored
Create a Claude comment workflow (#457)
* Create a Claude comment workflow to allow teammates to interact with Claude via comments and issues.
1 parent 4b8449e commit be38f10

File tree

1 file changed

+119
-0
lines changed

1 file changed

+119
-0
lines changed

.github/workflows/respond.yml

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
name: Claude Review
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
validation:
15+
name: Validation
16+
runs-on: ubuntu-24.04
17+
permissions:
18+
contents: read
19+
outputs:
20+
should_comment: ${{ steps.validate.outputs.should_comment }}
21+
22+
steps:
23+
- name: Check GitHub event
24+
id: check-github-event
25+
env:
26+
_EVENT_NAME: ${{ github.event_name }}
27+
_COMMENT_BODY: ${{ github.event.comment.body }}
28+
_REVIEW_BODY: ${{ github.event.review.body }}
29+
_ISSUE_BODY: ${{ github.event.issue.body }}
30+
run: |
31+
# Check if @claude is mentioned in the event
32+
MENTIONED=false
33+
34+
if [ "$_EVENT_NAME" == "issue_comment" ] && echo "$_COMMENT_BODY" | grep -qF "@claude"; then
35+
MENTIONED=true
36+
elif [ "$_EVENT_NAME" == "pull_request_review_comment" ] && echo "$_COMMENT_BODY" | grep -qF "@claude"; then
37+
MENTIONED=true
38+
elif [ "$_EVENT_NAME" == "pull_request_review" ] && echo "$_REVIEW_BODY" | grep -qF "@claude"; then
39+
MENTIONED=true
40+
elif [ "$_EVENT_NAME" == "issues" ] && echo "$_ISSUE_BODY" | grep -qF "@claude"; then
41+
MENTIONED=true
42+
fi
43+
44+
if [ "$MENTIONED" = "true" ]; then
45+
echo "claude_mentioned=true" >> $GITHUB_OUTPUT
46+
echo "✅ Validation: @claude mentioned in event"
47+
else
48+
echo "claude_mentioned=false" >> $GITHUB_OUTPUT
49+
echo "⏭️ Validation: @claude not mentioned - skipping"
50+
fi
51+
52+
- name: Check for Azure credentials
53+
id: check-azure-secret
54+
env:
55+
_AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
56+
_AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
57+
_AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
58+
run: |
59+
if [ -n "$_AZURE_SUBSCRIPTION_ID" ] && [ -n "$_AZURE_TENANT_ID" ] && [ -n "$_AZURE_CLIENT_ID" ]; then
60+
echo "credentials_valid=true" >> $GITHUB_OUTPUT
61+
echo "✅ Validation: Azure credentials available"
62+
else
63+
echo "credentials_valid=false" >> $GITHUB_OUTPUT
64+
echo "⚠️ Validation: Azure credentials not available"
65+
echo "This is expected for external contributors or forks"
66+
fi
67+
68+
- name: Set validation result
69+
id: validate
70+
run: |
71+
if [ "${{ steps.check-github-event.outputs.claude_mentioned }}" == "true" ] && \
72+
[ "${{ steps.check-azure-secret.outputs.credentials_valid }}" == "true" ]; then
73+
echo "should_comment=true" >> $GITHUB_OUTPUT
74+
echo "✅ Validation passed - comment will proceed"
75+
else
76+
echo "should_comment=false" >> $GITHUB_OUTPUT
77+
echo "⚠️ Validation failed - comment will be skipped"
78+
fi
79+
80+
comment:
81+
name: Claude comment
82+
runs-on: ubuntu-24.04
83+
needs: validation
84+
if: needs.validation.outputs.should_comment == 'true'
85+
permissions:
86+
contents: write
87+
pull-requests: write
88+
issues: write
89+
id-token: write
90+
actions: read
91+
92+
steps:
93+
- name: Check out repo
94+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
95+
with:
96+
fetch-depth: 1
97+
98+
- name: Log in to Azure
99+
uses: bitwarden/gh-actions/azure-login@main
100+
with:
101+
subscription_id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
102+
tenant_id: ${{ secrets.AZURE_TENANT_ID }}
103+
client_id: ${{ secrets.AZURE_CLIENT_ID }}
104+
105+
- name: Get Azure Key Vault secrets
106+
id: get-kv-secrets
107+
uses: bitwarden/gh-actions/get-keyvault-secrets@main
108+
with:
109+
keyvault: gh-org-bitwarden
110+
secrets: "ANTHROPIC-API-KEY"
111+
112+
- name: Log out from Azure
113+
uses: bitwarden/gh-actions/azure-logout@main
114+
115+
- name: Run Claude Code
116+
id: claude
117+
uses: anthropics/claude-code-action@e8bad572273ce919ba15fec95aef0ce974464753 # v1.0.13
118+
with:
119+
anthropic_api_key: ${{ steps.get-kv-secrets.outputs.ANTHROPIC-API-KEY }}

0 commit comments

Comments
 (0)