Skip to content

Add Critical tag to the PR desc #14

Add Critical tag to the PR desc

Add Critical tag to the PR desc #14

Workflow file for this run

name: Pull Request Reviewer
on:
pull_request:
types: [opened, reopened, edited]
workflow_call:
secrets:
SLACK_TOKEN:
required: true
CROSS_REPO_TOKEN:
required: true
OPENAI_API_KEY:
required: true
SLACK_CHANNEL_GIT_SECURITY:
required: true
jobs:
pr_reviewer_job:
runs-on: ubuntu-latest
name: A job to review pull request descriptions
steps:
- name: Checkout caller-repo
uses: actions/checkout@v4
- name: Checkout firefliesai/.github
uses: actions/checkout@v4
with:
repository: firefliesai/.github
path: firefliesai
ref: chore-sc-58666-add-the-critical-tag-in-the-pr-description
sparse-checkout-cone-mode: false
sparse-checkout: |
.github/scripts/PR_reviewer.js
- name: Save current PR description to file
id: save_pr_description
continue-on-error: true
run: printf "%q" "$(echo ${{ github.event.pull_request.body }})" > ${{ github.workspace }}/firefliesai/.github/PR_description.txt
- name: Search PR description in cache
id: cache
if: steps.save_pr_description.outcome == 'success'
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/firefliesai/.github/PR_description.txt
key: cache-pr-${{ github.event.pull_request.number }}-${{ hashFiles('./firefliesai/.github/PR_description.txt') }}
- name: Cache hit
if: steps.save_pr_description.outcome == 'success' && steps.cache.outputs.cache-hit == 'true'
run: echo "Cache hit for PR description, skipping PR Reviewer"
- name: Setup Node
if: steps.save_pr_description.outcome == 'failure' || steps.cache.outputs.cache-hit != 'true'
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: https://npm.pkg.github.com
scope: '@firefliesai'
- name: Install packages
if: steps.save_pr_description.outcome == 'failure' || steps.cache.outputs.cache-hit != 'true'
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
if: steps.save_pr_description.outcome == 'failure' || steps.cache.outputs.cache-hit != 'true'
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 }}
SLACK_CHANNEL_GIT_SECURITY: ${{ secrets.SLACK_CHANNEL_GIT_SECURITY }}
with:
script: |
const { reviewPR } = require('${{ github.workspace }}/firefliesai/.github/scripts/PR_reviewer.js');
if (!process.env.GTP_TOKEN) {
throw new Error('GTP_TOKEN is not set');
}
if (!process.env.OPENAI_API_KEY) {
throw new Error('OPENAI_API_KEY is not set');
}
if (!process.env.SLACK_TOKEN) {
throw new Error('SLACK_TOKEN is not set');
}
if (!process.env.SLACK_CHANNEL_GIT_SECURITY) {
throw new Error('SLACK_CHANNEL_GIT_SECURITY is not set');
}
await reviewPR(context);