Skip to content

Commit 9642219

Browse files
committed
automation
1 parent ba7342b commit 9642219

File tree

2 files changed

+197
-0
lines changed

2 files changed

+197
-0
lines changed
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: AI On-Demand Assistant
2+
on:
3+
issue_comment:
4+
types: [created]
5+
pull_request_review_comment:
6+
types: [created]
7+
pull_request_review:
8+
types: [submitted]
9+
issues:
10+
types: [opened]
11+
12+
jobs:
13+
ai-response:
14+
# Only run if the app is mentioned and it's not the app itself commenting
15+
if: |
16+
(
17+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@efp-dev-ops')) ||
18+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@efp-dev-ops')) ||
19+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@efp-dev-ops')) ||
20+
(github.event_name == 'issues' && contains(github.event.issue.body, '@efp-dev-ops'))
21+
) && (
22+
github.actor == '0xthrpw' ||
23+
github.actor == 'encrypteddegen' ||
24+
github.actor == 'caveman-eth' ||
25+
github.actor == 'brantlymillegan'
26+
)
27+
runs-on: ubuntu-latest
28+
permissions:
29+
contents: read
30+
issues: write
31+
pull-requests: write
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Generate Custom App Token
38+
id: generate-token
39+
uses: actions/create-github-app-token@v1
40+
with:
41+
app-id: ${{ secrets.APP_ID }}
42+
private-key: ${{ secrets.PRIVATE_KEY }}
43+
44+
- name: Extract instruction from comment
45+
id: extract-instruction
46+
run: |
47+
# Get the comment body based on event type
48+
if [ "${{ github.event_name }}" = "issue_comment" ]; then
49+
COMMENT_BODY="${{ github.event.comment.body }}"
50+
elif [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then
51+
COMMENT_BODY="${{ github.event.comment.body }}"
52+
elif [ "${{ github.event_name }}" = "pull_request_review" ]; then
53+
COMMENT_BODY="${{ github.event.review.body }}"
54+
elif [ "${{ github.event_name }}" = "issues" ]; then
55+
COMMENT_BODY="${{ github.event.issue.body }}"
56+
else
57+
COMMENT_BODY=""
58+
fi
59+
60+
# Remove the @mention and get the instruction
61+
INSTRUCTION=$(echo "$COMMENT_BODY" | sed 's/@efp-dev-ops[[:space:]]*//' | sed 's/^[[:space:]]*//')
62+
63+
# Set as output for next step
64+
echo "instruction<<EOF" >> $GITHUB_OUTPUT
65+
echo "$INSTRUCTION" >> $GITHUB_OUTPUT
66+
echo "EOF" >> $GITHUB_OUTPUT
67+
68+
echo "Extracted instruction: $INSTRUCTION"
69+
70+
- name: AI Response
71+
uses: anthropics/claude-code-action@v0
72+
with:
73+
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
74+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
75+
github_token: ${{ steps.generate-token.outputs.token }}
76+
direct_prompt: |
77+
You are an AI assistant for our development team. A team member has requested help with the following:
78+
79+
**User Request:** ${{ steps.extract-instruction.outputs.instruction }}
80+
81+
Please provide a helpful, accurate response. If the request involves code analysis, focus on the current repository context. If it's a general question, provide clear and actionable guidance.
82+
83+
Keep your response concise but thorough, and format it nicely for GitHub comments.
84+
85+
# - name: React to original comment
86+
# run: |
87+
# # Add a reaction to show the app "saw" the mention
88+
# if [ "${{ github.event_name }}" = "issue_comment" ] || [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then
89+
# gh api repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
90+
# --method POST \
91+
# --field content="+1"
92+
# elif [ "${{ github.event_name }}" = "pull_request_review" ]; then
93+
# gh api repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/reviews/${{ github.event.review.id }}/reactions \
94+
# --method POST \
95+
# --field content="+1"
96+
# elif [ "${{ github.event_name }}" = "issues" ]; then
97+
# gh api repos/${{ github.repository }}/issues/${{ github.event.issue.number }}/reactions \
98+
# --method POST \
99+
# --field content="+1"
100+
# fi
101+
env:
102+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}

.github/workflows/ai-review.yaml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Custom AI Code Review
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
# issue_comment:
6+
# types: [created]
7+
8+
jobs:
9+
ai-review:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
issues: write
15+
16+
steps:
17+
- name: Checkout code
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Get full history for better context
21+
22+
- name: Generate Custom App Token
23+
id: generate-token
24+
uses: actions/create-github-app-token@v1
25+
with:
26+
app-id: ${{ secrets.APP_ID }}
27+
private-key: ${{ secrets.PRIVATE_KEY }}
28+
29+
# - name: AI Security Review
30+
# uses: anthropics/claude-code-action@v0
31+
# with:
32+
# # anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
33+
# claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
34+
# github_token: ${{ steps.generate-token.outputs.token }}
35+
# direct_prompt: |
36+
# You are the AI security reviewer for our organization.
37+
38+
# Please analyze this pull request for:
39+
# 🛡️ **Security Vulnerabilities**
40+
# - SQL injection risks
41+
# - XSS vulnerabilities
42+
# - Authentication/authorization issues
43+
# - Input validation problems
44+
45+
# 📋 **Compliance Check**
46+
# - Follows our security coding standards
47+
# - Proper error handling
48+
# - Secure configuration practices
49+
50+
# Please provide specific, actionable feedback with line numbers where applicable.
51+
52+
- name: AI Code Quality Review
53+
uses: anthropics/claude-code-action@v0
54+
with:
55+
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
56+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
57+
github_token: ${{ steps.generate-token.outputs.token }}
58+
direct_prompt: |
59+
You are the AI code quality reviewer for our organization.
60+
61+
Please analyze this pull request for:
62+
63+
## 🔍 Code Quality Assessment
64+
- Overall code quality rating (1-10)
65+
- Code maintainability and readability
66+
- Adherence to best practices
67+
- Performance considerations
68+
69+
## 📚 Documentation Review
70+
- Comment quality and completeness
71+
- Function/method documentation
72+
- README updates if needed
73+
74+
## 🎯 Specific Recommendations
75+
- Actionable improvements with priorities
76+
- Code refactoring suggestions
77+
- Testing recommendations
78+
79+
Format your response as a professional code review.
80+
81+
- name: Post Summary Comment
82+
run: |
83+
gh pr comment ${{ github.event.number }} --body "
84+
## 🤖 AI Code Review Complete
85+
Your custom AI assistant has completed the automated code review process.
86+
87+
✅ Documentation review done
88+
89+
Please review the detailed feedback above and address any high-priority items before merging.
90+
91+
---
92+
*This automated review was performed by EFP-DEV-OPS*
93+
"
94+
env:
95+
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}

0 commit comments

Comments
 (0)