Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions .github/scripts/pr-draft-nudge.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ module.exports = async ({ github, context, core }) => {
}

// We only want to comment on PRs that are opened ready for review with reviewers.
if (
context.payload.action !== "opened" ||
pr.draft ||
!pr.requested_reviewers ||
pr.requested_reviewers.length === 0
) {
core.info(
'PR is a draft, has no reviewers, or this is not an "opened" event. Skipping.'
);
const hasIndividualReviewers = pr.requested_reviewers && pr.requested_reviewers.length > 0;
const hasTeamReviewers = pr.requested_teams && pr.requested_teams.length > 0;

// Debug reviewer information
core.debug(`PR requested_reviewers: ${JSON.stringify(pr.requested_reviewers || [])}`);
core.debug(`PR requested_teams: ${JSON.stringify(pr.requested_teams || [])}`);
core.debug(`Has individual reviewers: ${hasIndividualReviewers}`);
core.debug(`Has team reviewers: ${hasTeamReviewers}`);
core.debug(`PR action: ${context.payload.action}`);
core.debug(`PR is draft: ${pr.draft}`);

if (context.payload.action !== "opened" || pr.draft || (!hasIndividualReviewers && !hasTeamReviewers)) {
core.info('PR is a draft, has no reviewers (individual or team), or this is not an "opened" event. Skipping.');
return;
}

Expand All @@ -36,9 +40,7 @@ module.exports = async ({ github, context, core }) => {
issue_number: pr.number,
});

const existingComment = comments.find((comment) =>
comment.body.includes(commentIdentifier)
);
const existingComment = comments.find((comment) => comment.body.includes(commentIdentifier));

if (existingComment) {
core.info("A PR draft nudge comment already exists on this PR.");
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/do-not-merge-block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ on:

permissions: {}

env:
PATH_TO_REPO_SELF: gha-org-workflows

jobs:
do-not-merge-block:
name: Do Not Merge Block
Expand All @@ -27,13 +30,19 @@ jobs:
# Skip on merge group events
if: ${{ github.event_name == 'pull_request' }}
steps:
- uses: actions/checkout@v4
- name: Checkout org workflows
uses: actions/checkout@v4
with:
repository: smartcontractkit/${{ env.PATH_TO_REPO_SELF}}
path: ${{ env.PATH_TO_REPO_SELF}}
persist-credentials: false

- name: Fail if blocking label present
uses: actions/github-script@v7
env:
FAIL_LABELS: ${{ vars.DO_NOT_MERGE_LABELS || 'do-not-merge' }}
with:
script: |
const script = require('./.github/scripts/do-not-merge-block.js');
const pathToRepoSelf = process.env.PATH_TO_REPO_SELF || 'gha-org-workflows';
const script = require(`./${pathToRepoSelf}/.github/scripts/do-not-merge-block.js`);
await script({ context, core });
13 changes: 11 additions & 2 deletions .github/workflows/pr-draft-nudge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ on:

permissions: {}

env:
PATH_TO_REPO_SELF: gha-org-workflows

jobs:
pr-draft-nudge:
name: PR Draft Nudge
Expand All @@ -24,13 +27,19 @@ jobs:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Checkout org workflows
uses: actions/checkout@v4
with:
repository: smartcontractkit/${{ env.PATH_TO_REPO_SELF}}
path: ${{ env.PATH_TO_REPO_SELF}}
persist-credentials: false

- name: Run
uses: actions/github-script@v7
env:
PR_DRAFT_NUDGE_COMMENT_DISABLE: ${{ vars.PR_DRAFT_NUDGE_COMMENT_DISABLE || 'false' }}
with:
script: |
const script = require('./.github/scripts/pr-draft-nudge.js');
const pathToRepoSelf = process.env.PATH_TO_REPO_SELF || 'gha-org-workflows';
const script = require(`./${pathToRepoSelf}/.github/scripts/pr-draft-nudge.js`);
await script({ github, context, core });