Skip to content

Commit 14b739a

Browse files
authored
Merge pull request #1 from ethereumfollowprotocol/workflow
workflow
2 parents 7f8cef1 + 72fbdc9 commit 14b739a

2 files changed

Lines changed: 168 additions & 0 deletions

File tree

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: AI On-Demand Assistant
2+
description: "Provides AI assistance when @efp-dev-ops is mentioned by authorized users"
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
pull_request_review:
9+
types: [submitted]
10+
issues:
11+
types: [opened]
12+
13+
jobs:
14+
ai-response:
15+
# Only run if the app is mentioned and it's not the app itself commenting
16+
if: |
17+
(
18+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@efp-dev-ops')) ||
19+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@efp-dev-ops')) ||
20+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@efp-dev-ops')) ||
21+
(github.event_name == 'issues' && contains(github.event.issue.body, '@efp-dev-ops'))
22+
) && contains(fromJSON(vars.ALLOWED_USER_LIST), github.actor)
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
issues: write
27+
pull-requests: write
28+
29+
steps:
30+
- name: Checkout Code
31+
uses: actions/checkout@v4
32+
with:
33+
fetch-depth: 1
34+
35+
- name: Generate Custom App Token
36+
id: generate-token
37+
uses: actions/create-github-app-token@v1
38+
with:
39+
app-id: ${{ secrets.APP_ID }}
40+
private-key: ${{ secrets.PRIVATE_KEY }}
41+
42+
- name: Extract Instruction from Comment
43+
id: extract-instruction
44+
run: |
45+
# Get the comment body based on event type
46+
if [ "${{ github.event_name }}" = "issue_comment" ]; then
47+
COMMENT_BODY="${{ github.event.comment.body }}"
48+
elif [ "${{ github.event_name }}" = "pull_request_review_comment" ]; then
49+
COMMENT_BODY="${{ github.event.comment.body }}"
50+
elif [ "${{ github.event_name }}" = "pull_request_review" ]; then
51+
COMMENT_BODY="${{ github.event.review.body }}"
52+
elif [ "${{ github.event_name }}" = "issues" ]; then
53+
COMMENT_BODY="${{ github.event.issue.body }}"
54+
else
55+
COMMENT_BODY=""
56+
fi
57+
58+
# Remove the @mention and get the instruction
59+
INSTRUCTION=$(echo "$COMMENT_BODY" | sed 's/@efp-dev-ops[[:space:]]*//' | sed 's/^[[:space:]]*//')
60+
61+
# Add input validation
62+
if [ ${#INSTRUCTION} -gt 4000 ]; then
63+
echo "Instruction too long, truncating..."
64+
INSTRUCTION=$(echo "$INSTRUCTION" | head -c 4000)
65+
fi
66+
67+
# Set as output for next step
68+
echo "instruction<<EOF" >> $GITHUB_OUTPUT
69+
echo "$INSTRUCTION" >> $GITHUB_OUTPUT
70+
echo "EOF" >> $GITHUB_OUTPUT
71+
72+
echo "Extracted instruction: $INSTRUCTION"
73+
74+
- name: AI Response
75+
uses: anthropics/claude-code-action@v0
76+
continue-on-error: true
77+
timeout-minutes: 10
78+
with:
79+
# anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
80+
claude_code_oauth_token: ${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }}
81+
github_token: ${{ steps.generate-token.outputs.token }}
82+
direct_prompt: |
83+
You are an AI assistant for our development team. A team member has requested help with the following:
84+
85+
**User Request:** ${{ steps.extract-instruction.outputs.instruction }}
86+
87+
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.
88+
89+
Keep your response concise but thorough, and format it nicely for GitHub comments.

.github/workflows/ai-review.yaml

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

0 commit comments

Comments
 (0)