Skip to content

Commit

Permalink
Merge pull request #12 from MikeBirdTech/pr-writer-action
Browse files Browse the repository at this point in the history
**Improve PR Writer Workflow and Script**
  • Loading branch information
MikeBirdTech authored Sep 19, 2024
2 parents 02192cb + c517ae3 commit 6efb8e7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions .github/pr-writer/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,19 @@ inputs:
github_token:
description: "GitHub token"
required: true

runs:
using: "composite"
steps:
- uses: actions/checkout@v4 # Checks out your repository code
- uses: actions/setup-python@v4
with:
python-version: "3.x"
- run: pip install PyGithub groq
- run: pip install -r ./.github/pr-writer/requirements.txt
shell: bash
- run: ls -la ./.github/pr-writer/
shell: bash
- run: python ${{ github.action_path }}/generate_summary.py
- run: python ./.github/pr-writer/pr-writer.py
shell: bash
env:
GROQ_API_KEY: ${{ inputs.groq_api_key }}
Expand Down
5 changes: 5 additions & 0 deletions .github/pr-writer/pr-writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def generate_summary(commit_messages):
- **Notes**: Any important considerations or follow-up actions.
Maintain a professional and clear tone appropriate for a developer audience.
Do not write "PR Title" or "PR Description" in the fields. No preamble
"""

response = groq_client.chat.completions.create(
Expand Down Expand Up @@ -74,6 +76,9 @@ def main():
description = "\n".join(lines[1:]).strip()

update_pr(repo_name, pr_number, title, description)
except KeyError as e:
print(f"Missing environment variable: {e}")
sys.exit(1)
except Exception as e:
print(f"An error occurred: {e}")
sys.exit(1)
Expand Down
2 changes: 2 additions & 0 deletions .github/pr-writer/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PyGithub
groq
2 changes: 0 additions & 2 deletions .github/todo-issue-creator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,3 @@ jobs:
groq_api_key: \${{ secrets.GROQ_API_KEY }}
github_token: \${{ secrets.GITHUB_TOKEN }}
```
<!-- TODO: Add better instructions for set up -->
7 changes: 5 additions & 2 deletions .github/workflows/pr-writer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ permissions:

jobs:
summarize:
if: ${{ github.event.sender.login != 'github-actions[bot]' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate PR Summary
uses: ./.github/pr-summary
uses: ./.github/pr-writer
with:
groq_api_key: ${{ secrets.GROQ_API_KEY }}
github_token: ${{ secrets.GH_TOKEN }}

0 comments on commit 6efb8e7

Please sign in to comment.