Skip to content

chore(ci): add workflow to suggest splitting large PRs #1480

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

25 changes: 25 additions & 0 deletions .github/scripts/comment_on_large_pr.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const {
PR_NUMBER,
IGNORE_AUTHORS,
} = require("./constants")

module.exports = async ({github, context, core}) => {
if (IGNORE_AUTHORS.includes(PR_AUTHOR)) {
return core.notice("Author in IGNORE_AUTHORS list; skipping...")
}

core.info(`Commenting on PR ${PR_NUMBER}`)

let msg = `
### ⚠️Large PR detected⚠️.
Please consider breaking into smaller PRs to avoid significant review delays. Ignore if this PR has naturally grown to this size after reviews.
`;

await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
body: msg,
issue_number: PR_NUMBER,
});
}
25 changes: 25 additions & 0 deletions .github/workflows/on_label_added.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: On Label added

on:
pull_request:
types:
- labeled

jobs:
split-large-pr:
if: github.event.label.name == 'size/XXL'
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- name: "Suggest split large Pull Request"
uses: actions/github-script@v6
env:
PR_NUMBER: ${{ github.event.issue.number }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const script = require('.github/scripts/comment_on_large_pr.js')
await script({github, context, core})