Skip to content

Add the PR description reviewer workflow #3

Add the PR description reviewer workflow

Add the PR description reviewer workflow #3

Workflow file for this run

name: Pull Request Reviewer
on:
pull_request:
types: [opened, reopened, edited]
jobs:
pr_reviewer_job:
runs-on: ubuntu-latest
name: A job to review pull request descriptions
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: https://npm.pkg.github.com
scope: '@firefliesai'
- name: Install packages
env:
GTP_TOKEN: ${{ secrets.CROSS_REPO_TOKEN }}
run: |
[ -f package.json ] && mv package.json package.json.xx
npm install openai @octokit/rest @slack/web-api slackify-markdown
- name: Run PR Reviewer
uses: actions/github-script@v6
id: reviewer
env:
GTP_TOKEN: ${{ secrets.CROSS_REPO_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
with:
script: |
const { Octokit } = require('@octokit/rest');
const OpenAI = require('openai');
const { WebClient } = require('@slack/web-api');
const format = require('slackify-markdown');
console.log('workspace...', '${{ github.workspace }}');
const { reviewPR } = require('${{ github.workspace }}/scripts/PR_reviewer.js');
// OCTOKIT REFERENCE: https://octokit.github.io/rest.js/v20
const octokit = new Octokit({
auth: process.env.GTP_TOKEN,
request: {
fetch,
},
});
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const slack = new WebClient(process.env.SLACK_TOKEN);
await reviewPR({ openai, octokit, slack, format, context });