Skip to content

Commit 6c7151c

Browse files
Initial Commit
0 parents  commit 6c7151c

16 files changed

+38190
-0
lines changed
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build and Release
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- 'v*.*.*'
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Node.js
20+
uses: actions/setup-node@v4
21+
with:
22+
node-version: '20'
23+
24+
- name: Install dependencies
25+
run: npm install
26+
27+
- name: Build action
28+
run: npm run build
29+
30+
- name: Verify build
31+
run: |
32+
if [ ! -d 'dist' ]; then
33+
echo "Build failed - dist directory not found"
34+
exit 1
35+
fi
36+
echo "Build successful"
37+
38+
- name: Upload build artifacts
39+
uses: actions/upload-artifact@v4
40+
with:
41+
name: dist
42+
path: dist/
43+
retention-days: 1
44+
45+
release:
46+
needs: build
47+
if: startsWith(github.ref, 'refs/tags/')
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- name: Download build artifacts
53+
uses: actions/download-artifact@v4
54+
with:
55+
name: dist
56+
path: dist/
57+
58+
- name: Create GitHub Release
59+
id: create_release
60+
uses: softprops/action-gh-release@v2
61+
with:
62+
name: Release ${{ github.ref_name }}
63+
tag_name: ${{ github.ref_name }}
64+
body: |
65+
## Release Notes
66+
- Built from ${{ github.sha }}
67+
- Automated release
68+
generate_release_notes: true
69+
draft: false
70+
prerelease: ${{ contains(github.ref_name, '-') }}
71+
files: |
72+
dist/index.js

.github/workflows/pr-review.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: SenpAI Code Review
2+
on:
3+
pull_request:
4+
types: [opened, synchronize, reopened]
5+
issue_comment:
6+
types: [created]
7+
8+
jobs:
9+
code-review:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: read
13+
pull-requests: write
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Run SenpAI Review
18+
uses: dicodingacademy/senpai-action@v0.0.1
19+
with:
20+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
22+
GEMINI_MODEL: 'gemini-1.5-flash-002'
23+
EXCLUDE_FILES: '*.md, *.json, *.lock'
24+
TRIGGER_COMMAND: '/review'
25+
LANGUAGE_REVIEW: 'indonesia'
26+
TONE_RESPONSE: 'professional'

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea
2+
node_modules

README.md

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# SenpAI (先輩) - Senior Programmer AI
2+
3+
![GitHub Action](https://img.shields.io/badge/GitHub%20Action-AI%20Code%20Review-blue)
4+
![Gemini](https://img.shields.io/badge/Powered%20By-Google%20Gemini-orange)
5+
6+
SenpAI is an AI-powered GitHub Action that automatically reviews pull requests using Google's Gemini AI model. It provides detailed, line-by-line feedback on code quality, security, and performance.
7+
8+
---
9+
10+
## Features
11+
12+
- **AI-Powered Code Reviews**: Uses Google Gemini for intelligent code analysis
13+
- **Customizable**: Set review language, tone, and exclusions
14+
- **Line-by-Line Feedback**: Comments directly on problematic code
15+
- **Trigger Support**: Run via `/review` command or automatically
16+
- **File Exclusions**: Skip files using glob patterns
17+
---
18+
19+
## Usage
20+
### 1. Get Your Gemini API Key:
21+
22+
Sign up for an API key at [Google AI Studio](https://makersuite.google.com/app/apikey) if you don’t have one.
23+
24+
### 2. Add the API Key to GitHub Secrets:
25+
- Click on Settings > Secrets and variables > Actions.
26+
- Click New repository secret.
27+
- Name it GEMINI_API_KEY and paste your API key in the value field.
28+
- Click Add secret.
29+
30+
### 3. Add to Your Workflow
31+
32+
Create `.github/workflows/review.yml`:
33+
34+
```yaml
35+
name: SenpAI Code Review
36+
on:
37+
pull_request:
38+
types: [opened, synchronize, reopened]
39+
issue_comment:
40+
types: [created]
41+
42+
jobs:
43+
code-review:
44+
runs-on: ubuntu-latest
45+
permissions:
46+
contents: read
47+
pull-requests: write
48+
steps:
49+
- uses: actions/checkout@v4
50+
51+
- name: Run SenpAI Review
52+
uses: dicodingacademy/senpai@latest
53+
with:
54+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
55+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
56+
GEMINI_MODEL: 'gemini-1.5-flash-002'
57+
EXCLUDE_FILES: '*.md, *.json, *.lock'
58+
TRIGGER_COMMAND: '/review'
59+
LANGUAGE_REVIEW: 'english'
60+
TONE_RESPONSE: 'professional'

action.yml

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: "senpai-action"
2+
description: "Auto-reviews pull requests with Google's Gemini AI, offering insightful feedback and suggestions to enhance code quality."
3+
author: 'furqoncreative'
4+
5+
inputs:
6+
GITHUB_TOKEN:
7+
description: 'GitHub token to interact with the repository'
8+
required: true
9+
GEMINI_API_KEY:
10+
description: 'Google Gemini API key for accessing AI-powered code reviews'
11+
required: true
12+
GEMINI_MODEL:
13+
description: 'The specific Gemini model used for code review and feedback'
14+
required: false
15+
default: 'gemini-2.0-flash'
16+
EXCLUDE_FILES:
17+
description: 'Comma-separated list of file patterns to exclude from the review process'
18+
required: false
19+
default: ''
20+
TRIGGER_COMMAND:
21+
description: 'Command to manually trigger a code review'
22+
required: false
23+
default: '/review'
24+
LANGUAGE_REVIEW:
25+
description: 'The language in which review comments and feedback will be provided'
26+
required: false
27+
default: 'english'
28+
TONE_RESPONSE:
29+
description: 'The tone of the feedback, such as professional, friendly, or concise'
30+
required: false
31+
default: 'professional'
32+
33+
runs:
34+
using: 'node20'
35+
main: 'dist/index.js'
36+
37+
branding:
38+
icon: 'code'
39+
color: 'red'

0 commit comments

Comments
 (0)