Skip to content

Commit ed26ce3

Browse files
authored
refactor: optimize contributor workflow to use check_suite (#4819)
* refactor: use check_suite instead of check_run for contributor workflow The contributors workflow was triggering after every individual check completion. By switching to the check_suite event, it will now only run once after all checks in a suite have completed, reducing unnecessary workflow runs. Changes: - Changed trigger from check_run to check_suite - Updated condition logic to handle check_suite event payload - Updated script to extract PR number from check_suite.pull_requests Signed-off-by: Mark Phelps <[email protected]> * refactor: only run contributor workflow on check suite failure Updated the workflow to only trigger when the check suite fails, avoiding unnecessary runs when all checks pass successfully. Signed-off-by: Mark Phelps <[email protected]> * refactor: rename job to check-dco Signed-off-by: Mark Phelps <[email protected]> --------- Signed-off-by: Mark Phelps <[email protected]>
1 parent 0734128 commit ed26ce3

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

.github/workflows/contributors.yml

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Contributor Assistant
33
on:
44
pull_request_target:
55
types: [opened]
6-
check_run:
6+
check_suite:
77
types: [completed]
88

99
permissions:
@@ -12,15 +12,14 @@ permissions:
1212
checks: read
1313

1414
jobs:
15-
post-dco-comment:
15+
check-dco:
1616
runs-on: ubuntu-latest
17-
# Only run for PR opened events or when DCO check specifically fails
17+
# Only run for PR opened events or when check suite completes with failure
1818
if: |
19-
github.event_name == 'pull_request_target' ||
20-
(github.event_name == 'check_run' &&
21-
github.event.check_run.name == 'DCO' &&
22-
github.event.check_run.conclusion == 'failure' &&
23-
github.event.check_run.pull_requests[0] != null)
19+
github.event_name == 'pull_request_target' ||
20+
(github.event_name == 'check_suite' &&
21+
github.event.check_suite.conclusion == 'failure' &&
22+
github.event.check_suite.pull_requests[0] != null)
2423
steps:
2524
- name: Get Pull Request and Check DCO Status
2625
id: check_dco
@@ -29,16 +28,16 @@ jobs:
2928
github-token: ${{ secrets.GITHUB_TOKEN }}
3029
script: |
3130
let prNumber;
32-
31+
3332
// Get PR number based on event type
3433
if (context.eventName === 'pull_request_target') {
3534
prNumber = context.issue.number;
36-
} else if (context.eventName === 'check_run') {
37-
const pulls = context.payload.check_run.pull_requests;
35+
} else if (context.eventName === 'check_suite') {
36+
const pulls = context.payload.check_suite.pull_requests;
3837
if (pulls && pulls.length > 0) {
3938
prNumber = pulls[0].number;
4039
} else {
41-
console.log('No PR associated with this check run');
40+
console.log('No PR associated with this check suite');
4241
return;
4342
}
4443
}

0 commit comments

Comments
 (0)