Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/ai-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,10 @@ jobs:
issues: write

steps:
- name: Checkout code
- name: Checkout repository
uses: actions/checkout@v4

- name: AI Code Review
- name: Run CodeBuddy AI
uses: ./
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ Thumbs.db
# Logs
*.log
npm-debug.log*
dist/
lib/
33 changes: 29 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'AI Code Review Bot'
description: 'Automatically reviews pull requests using Google Gemini AI'
name: 'CodeBuddy AI'
description: 'Your friendly AI code reviewer powered by Google Gemini'
author: 'Your Name'
branding:
icon: 'check-circle'
Expand All @@ -11,5 +11,30 @@ inputs:
required: true

runs:
using: 'node20'
main: 'dist/index.js'
using: 'composite'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Install dependencies
shell: bash
run: |
cd ${{ github.action_path }}
npm ci

- name: Build action
shell: bash
run: |
cd ${{ github.action_path }}
npm run build

- name: Run CodeBuddy AI
shell: bash
env:
INPUT_GEMINI_API_KEY: ${{ inputs.gemini_api_key }}
GITHUB_TOKEN: ${{ github.token }}
run: |
cd ${{ github.action_path }}
node dist/index.js
21 changes: 11 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"name": "ai-code-review-bot",
"name": "codebuddy-ai",
"version": "1.0.0",
"main": "index.js",
"description": "Your friendly AI code reviewer powered by Google Gemini",
"main": "dist/index.js",
"scripts": {
"build": "ncc build src/index.ts -o dist",
"build:watch": "ncc build src/index.ts -o dist --watch",
"build": "tsc && ncc build lib/index.js -o dist",
"build:watch": "ncc build lib/index.js -o dist --watch",
"clean": "rm -rf dist lib",
"all": "npm run clean && npm run build"
},
"keywords": [],
"author": "Ratan Gulati",
"license": "ISC",
"description": "",
"keywords": ["github-actions", "ai", "code-review", "gemini"],
"author": "Your Name",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.11.1",
"@actions/github": "^6.0.1",
"node-fetch": "^3.3.2"
"node-fetch": "^2.7.0"
},
"devDependencies": {
"@types/node": "^24.3.0",
"@types/node": "^20.14.0",
"@types/node-fetch": "^2.6.11",
"@vercel/ncc": "^0.38.3",
"typescript": "^5.9.2"
}
Expand Down
33 changes: 33 additions & 0 deletions sample-code.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Sample code with various issues for AI review
function calculateTotal(items) {
let total = 0;
for (let i = 0; i < items.length; i++) {
total = total + items[i].price;
}
return total;
}

// Missing error handling
function fetchUserData(userId) {
return fetch(`https://api.example.com/users/${userId}`)
.then(response => response.json());
}

// Security issue: SQL injection vulnerability
function getUser(username) {
const query = "SELECT * FROM users WHERE username = '" + username + "'";
return db.query(query);
}

// Performance issue: inefficient loop
function findDuplicates(arr) {
let duplicates = [];
for (let i = 0; i < arr.length; i++) {
for (let j = i + 1; j < arr.length; j++) {
if (arr[i] === arr[j]) {
duplicates.push(arr[i]);
}
}
}
return duplicates;
}
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -245,3 +245,4 @@ async function run() {
}

run();
// test
Loading