Skip to content
Merged
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
11 changes: 10 additions & 1 deletion .github/workflows/summarizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
types: [opened, synchronize, reopened]

permissions:
pull-requests: write
contents: read

jobs:
summarize:
runs-on: ubuntu-latest
Expand All @@ -26,4 +30,9 @@ jobs:
env:
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: python src/main.py
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: |
python main.py > summary.txt
SUMMARY=$(cat summary.txt)
echo "$SUMMARY"
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# nopejs Bot

➤ Auto-generates concise summaries for GitHub pull requests using Gemini.

## Overview

nopejs is a GitHub Action that triggers on PR events, analyzes the PR content, and posts a summary.
2 changes: 1 addition & 1 deletion src/__init__.py → __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
GitHub PR Summarizer Bot

This package uses the Gemini API to summarize pull requests.
"""
"""
7 changes: 5 additions & 2 deletions src/main.py → main.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

GITHUB_API = "https://api.github.com"
REPO = os.getenv("GITHUB_REPOSITORY")
PR_NUMBER = os.getenv("GITHUB_REF").split("/")[-1]
PR_NUMBER = os.getenv("PR_NUMBER")
TOKEN = os.getenv("GITHUB_TOKEN")

headers = {
Expand All @@ -30,6 +30,9 @@ def post_comment(comment):
requests.post(url, headers=headers, json={"body": comment})

if __name__ == "__main__":
if not os.getenv("GEMINI_API_KEY"):
print("[DEBUG] GEMINI_API_KEY is not set.")
pr_body, diff = get_pr_data()
summary = generate_summary(pr_body, diff)
post_comment(f"**PR Summary**\n\n{summary}")
post_comment(f"**PR Summary**\n\n{summary}")
print(summary)
17 changes: 13 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@

from setuptools import setup, find_packages

import os

def readme():
try:
with open(os.path.join(os.path.dirname(__file__), 'README.md')) as f:
return f.read()
except Exception:
return ''

setup(
name='github-pr-summarizer',
version='0.1.0',
packages=find_packages(where="src"),
package_dir={"": "src"},
packages=find_packages(),
install_requires=[
'google-generativeai>=0.3.2',
'requests>=2.31.0',
Expand All @@ -17,11 +26,11 @@
},
author='Your Name',
description='A GitHub Action bot that summarizes pull requests using Google Gemini API',
long_description=open('README.md').read(),
long_description=readme(),
long_description_content_type='text/markdown',
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
],
python_requires='>=3.8',
)
)
File renamed without changes.