diff --git a/.github/scripts/comment_on_large_pr.js b/.github/scripts/comment_on_large_pr.js new file mode 100644 index 00000000000..5d469c1635c --- /dev/null +++ b/.github/scripts/comment_on_large_pr.js @@ -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, + }); +} diff --git a/.github/workflows/on_label_added.yml b/.github/workflows/on_label_added.yml new file mode 100644 index 00000000000..fd4064e5c6a --- /dev/null +++ b/.github/workflows/on_label_added.yml @@ -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})