diff --git a/validate-pr/README.md b/validate-pr/README.md index 56ea8ad..7549c77 100644 --- a/validate-pr/README.md +++ b/validate-pr/README.md @@ -4,10 +4,9 @@ Validates non-maintainer pull requests against contribution guidelines. ## What it does -1. **Validates issue references** — Non-maintainer PRs must reference a GitHub issue where the PR author and a maintainer have discussed the approach. PRs that don't meet this requirement are automatically closed with a descriptive comment. -2. **Enforces draft status** — All PRs must start as drafts. Non-draft PRs are automatically converted and labeled. +**Validates issue references** — Non-maintainer PRs must reference a GitHub issue where the PR author and a maintainer have discussed the approach. PRs that don't meet this requirement are automatically closed with a descriptive comment. -Maintainers (users with `admin` or `maintain` role) are exempt from the issue reference validation. Draft enforcement applies to everyone. +Maintainers (users with `admin` or `maintain` role) are exempt from validation. ## Usage @@ -61,10 +60,6 @@ A PR is valid if **any** referenced issue passes all checks: - If the issue has assignees, the PR author must be one of them - Both the PR author and a maintainer have participated in the issue discussion -### Draft enforcement - -Non-draft PRs are converted to draft and labeled `converted-to-draft` with an informational comment. - ## Labels The action creates these labels automatically (they don't need to exist beforehand): @@ -73,4 +68,3 @@ The action creates these labels automatically (they don't need to exist beforeha - `missing-issue-reference` — PR body has no issue references - `missing-maintainer-discussion` — referenced issue lacks author + maintainer discussion - `issue-already-assigned` — referenced issue is assigned to someone else -- `converted-to-draft` — PR was automatically converted to draft diff --git a/validate-pr/action.yml b/validate-pr/action.yml index 834b210..b305549 100644 --- a/validate-pr/action.yml +++ b/validate-pr/action.yml @@ -1,5 +1,5 @@ name: 'Validate PR' -description: 'Validates non-maintainer PRs against contribution guidelines and enforces draft status' +description: 'Validates non-maintainer PRs against contribution guidelines' author: 'Sentry' inputs: @@ -33,26 +33,3 @@ runs: script: | const script = require('${{ github.action_path }}/scripts/validate-pr.js'); await script({ github, context, core }); - - - name: Convert PR to draft - if: >- - steps.validate.outputs.was-closed != 'true' - && steps.validate.outputs.skipped != 'true' - && github.event.pull_request.draft == false - shell: bash - env: - GH_TOKEN: ${{ steps.app-token.outputs.token }} - PR_URL: ${{ github.event.pull_request.html_url }} - run: gh pr ready "$PR_URL" --undo - - - name: Label and comment on draft conversion - if: >- - steps.validate.outputs.was-closed != 'true' - && steps.validate.outputs.skipped != 'true' - && github.event.pull_request.draft == false - uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 - with: - github-token: ${{ steps.app-token.outputs.token }} - script: | - const script = require('${{ github.action_path }}/scripts/enforce-draft.js'); - await script({ github, context, core }); diff --git a/validate-pr/scripts/enforce-draft.js b/validate-pr/scripts/enforce-draft.js deleted file mode 100644 index f7aa4aa..0000000 --- a/validate-pr/scripts/enforce-draft.js +++ /dev/null @@ -1,51 +0,0 @@ -// @ts-check - -/** - * Labels a PR that was converted to draft and leaves an informational comment. - * Skips if a bot comment already exists (to avoid duplicates on reopen). - * - * @param {object} params - * @param {import('@actions/github').getOctokit} params.github - * @param {import('@actions/github').context} params.context - * @param {import('@actions/core')} params.core - */ -module.exports = async ({ github, context, core }) => { - const pullRequest = context.payload.pull_request; - const repo = context.repo; - - await github.rest.issues.addLabels({ - ...repo, - issue_number: pullRequest.number, - labels: ['converted-to-draft'], - }); - - // Check for existing bot comment to avoid duplicates on reopen - const comments = await github.paginate(github.rest.issues.listComments, { - ...repo, - issue_number: pullRequest.number, - per_page: 100, - }); - const botComment = comments.find(c => - c.user?.type === 'Bot' && - c.body.includes('automatically converted to draft') - ); - if (botComment) { - core.info('Bot comment already exists, skipping.'); - return; - } - - const contributingUrl = `https://github.com/${repo.owner}/${repo.repo}/blob/${context.payload.repository.default_branch}/CONTRIBUTING.md`; - - await github.rest.issues.createComment({ - ...repo, - issue_number: pullRequest.number, - body: [ - `This PR has been automatically converted to draft. All PRs must start as drafts per our [contributing guidelines](${contributingUrl}).`, - '', - '**Next steps:**', - '1. Ensure CI passes', - '2. Fill in the PR description completely', - '3. Mark as "Ready for review" when you\'re done', - ].join('\n'), - }); -};