From 26d14ae0abf4c82f6c8a16790b1da46fa9fac089 Mon Sep 17 00:00:00 2001 From: sabique Date: Fri, 18 Jul 2025 22:59:43 +0530 Subject: [PATCH 1/6] docs: add project README.md with overview --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index e69de29..da6b3eb 100644 --- a/README.md +++ b/README.md @@ -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. \ No newline at end of file From 16d5149bae88d9b3f67e03d9d9d7ccbaed31e7da Mon Sep 17 00:00:00 2001 From: sabique Date: Fri, 18 Jul 2025 23:08:26 +0530 Subject: [PATCH 2/6] chore: add debug statement to print the summary output --- .github/workflows/summarizer.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/summarizer.yml b/.github/workflows/summarizer.yml index ea262c1..a36f5b0 100644 --- a/.github/workflows/summarizer.yml +++ b/.github/workflows/summarizer.yml @@ -26,4 +26,7 @@ jobs: env: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: python src/main.py \ No newline at end of file + run: | + SUMMARY=$(python src/main.py) + echo "----- SUMMARY OUTPUT BELOW -----" + echo "$SUMMARY" \ No newline at end of file From 813c72bf4aa44d1eba0e708daf17711e945e5b0c Mon Sep 17 00:00:00 2001 From: sabique Date: Fri, 18 Jul 2025 23:22:17 +0530 Subject: [PATCH 3/6] feat: pls work --- .github/workflows/summarizer.yml | 4 ++-- src/__init__.py => __init__.py | 2 +- src/main.py => main.py | 2 ++ setup.py | 17 +++++++++++++---- src/summarizer.py => summarizer.py | 0 5 files changed, 18 insertions(+), 7 deletions(-) rename src/__init__.py => __init__.py (95%) rename src/main.py => main.py (92%) rename src/summarizer.py => summarizer.py (100%) diff --git a/.github/workflows/summarizer.yml b/.github/workflows/summarizer.yml index a36f5b0..ba91639 100644 --- a/.github/workflows/summarizer.yml +++ b/.github/workflows/summarizer.yml @@ -27,6 +27,6 @@ jobs: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | - SUMMARY=$(python src/main.py) - echo "----- SUMMARY OUTPUT BELOW -----" + python main.py > summary.txt + SUMMARY=$(cat summary.txt) echo "$SUMMARY" \ No newline at end of file diff --git a/src/__init__.py b/__init__.py similarity index 95% rename from src/__init__.py rename to __init__.py index d977131..5f97dab 100644 --- a/src/__init__.py +++ b/__init__.py @@ -2,4 +2,4 @@ GitHub PR Summarizer Bot This package uses the Gemini API to summarize pull requests. -""" \ No newline at end of file +""" diff --git a/src/main.py b/main.py similarity index 92% rename from src/main.py rename to main.py index c739545..1d7b3f5 100644 --- a/src/main.py +++ b/main.py @@ -30,6 +30,8 @@ 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}") \ No newline at end of file diff --git a/setup.py b/setup.py index a4af97e..f92d880 100644 --- a/setup.py +++ b/setup.py @@ -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', @@ -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', -) +) \ No newline at end of file diff --git a/src/summarizer.py b/summarizer.py similarity index 100% rename from src/summarizer.py rename to summarizer.py From c247422ea22eba4f7467de4e1613138ad34624a1 Mon Sep 17 00:00:00 2001 From: sabique Date: Fri, 18 Jul 2025 23:26:31 +0530 Subject: [PATCH 4/6] feat: add summary print statement --- main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 1d7b3f5..647479c 100644 --- a/main.py +++ b/main.py @@ -34,4 +34,5 @@ def post_comment(comment): 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}") \ No newline at end of file + post_comment(f"**PR Summary**\n\n{summary}") + print(summary) \ No newline at end of file From 90b551fe3a00d7e3a279b083ff281e4eb09c71b1 Mon Sep 17 00:00:00 2001 From: sabique Date: Fri, 18 Jul 2025 23:34:07 +0530 Subject: [PATCH 5/6] fix: work pls --- .github/workflows/summarizer.yml | 2 ++ main.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/summarizer.yml b/.github/workflows/summarizer.yml index ba91639..ddbab00 100644 --- a/.github/workflows/summarizer.yml +++ b/.github/workflows/summarizer.yml @@ -26,6 +26,8 @@ jobs: env: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PR_NUMBER: ${{ github.event.pull_request.number }} + GITHUB_REPOSITORY: ${{ github.repository }}- run: | python main.py > summary.txt SUMMARY=$(cat summary.txt) diff --git a/main.py b/main.py index 647479c..db371c9 100644 --- a/main.py +++ b/main.py @@ -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 = { From c94338b6e0ae026b115da65a9478c37f64159fd6 Mon Sep 17 00:00:00 2001 From: sabique Date: Fri, 18 Jul 2025 23:38:02 +0530 Subject: [PATCH 6/6] fix: pr comment pls work .... --- .github/workflows/summarizer.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/summarizer.yml b/.github/workflows/summarizer.yml index ddbab00..11e0cd3 100644 --- a/.github/workflows/summarizer.yml +++ b/.github/workflows/summarizer.yml @@ -4,6 +4,10 @@ on: pull_request: types: [opened, synchronize, reopened] +permissions: + pull-requests: write + contents: read + jobs: summarize: runs-on: ubuntu-latest @@ -27,7 +31,7 @@ jobs: GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PR_NUMBER: ${{ github.event.pull_request.number }} - GITHUB_REPOSITORY: ${{ github.repository }}- + GITHUB_REPOSITORY: ${{ github.repository }} run: | python main.py > summary.txt SUMMARY=$(cat summary.txt)