Skip to content

Commit 2810d15

Browse files
committed
Merge branch 'main' into dx-1203/do-not-merge-removal
2 parents bbf7a38 + 3dd0995 commit 2810d15

File tree

2 files changed

+25
-14
lines changed

2 files changed

+25
-14
lines changed

.github/scripts/pr-draft-nudge.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@ module.exports = async ({ github, context, core }) => {
1313
}
1414

1515
// We only want to comment on PRs that are opened ready for review with reviewers.
16-
if (
17-
context.payload.action !== "opened" ||
18-
pr.draft ||
19-
!pr.requested_reviewers ||
20-
pr.requested_reviewers.length === 0
21-
) {
22-
core.info(
23-
'PR is a draft, has no reviewers, or this is not an "opened" event. Skipping.'
24-
);
16+
const hasIndividualReviewers = pr.requested_reviewers && pr.requested_reviewers.length > 0;
17+
const hasTeamReviewers = pr.requested_teams && pr.requested_teams.length > 0;
18+
19+
// Debug reviewer information
20+
core.debug(`PR requested_reviewers: ${JSON.stringify(pr.requested_reviewers || [])}`);
21+
core.debug(`PR requested_teams: ${JSON.stringify(pr.requested_teams || [])}`);
22+
core.debug(`Has individual reviewers: ${hasIndividualReviewers}`);
23+
core.debug(`Has team reviewers: ${hasTeamReviewers}`);
24+
core.debug(`PR action: ${context.payload.action}`);
25+
core.debug(`PR is draft: ${pr.draft}`);
26+
27+
if (context.payload.action !== "opened" || pr.draft || (!hasIndividualReviewers && !hasTeamReviewers)) {
28+
core.info('PR is a draft, has no reviewers (individual or team), or this is not an "opened" event. Skipping.');
2529
return;
2630
}
2731

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

39-
const existingComment = comments.find((comment) =>
40-
comment.body.includes(commentIdentifier)
41-
);
43+
const existingComment = comments.find((comment) => comment.body.includes(commentIdentifier));
4244

4345
if (existingComment) {
4446
core.info("A PR draft nudge comment already exists on this PR.");

.github/workflows/pr-draft-nudge.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ on:
1515

1616
permissions: {}
1717

18+
env:
19+
PATH_TO_REPO_SELF: gha-org-workflows
20+
1821
jobs:
1922
pr-draft-nudge:
2023
name: PR Draft Nudge
@@ -24,13 +27,19 @@ jobs:
2427
contents: read
2528
pull-requests: write
2629
steps:
27-
- uses: actions/checkout@v4
30+
- name: Checkout org workflows
31+
uses: actions/checkout@v4
32+
with:
33+
repository: smartcontractkit/${{ env.PATH_TO_REPO_SELF}}
34+
path: ${{ env.PATH_TO_REPO_SELF}}
35+
persist-credentials: false
2836

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

0 commit comments

Comments
 (0)