Skip to content

Commit 2ad0b2a

Browse files
andekandeshine2lay
andauthored
fix: Comments on Issues should not trigger 'checks' action (#759)
Co-authored-by: Shine Lee <[email protected]>
1 parent c1751e2 commit 2ad0b2a

File tree

4 files changed

+18
-4
lines changed

4 files changed

+18
-4
lines changed

__fixtures__/unit/helper.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ module.exports = {
6464
user: {
6565
login: 'creator'
6666
},
67-
number: (options.number) ? options.number : 1
67+
number: (options.number) ? options.number : 1,
68+
pull_request: {}
6869
}
6970
},
7071
log: {

docs/changelog.rst

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
CHANGELOG
22
=====================================
3+
| June 20, 2024: fix: Comments on Issues should not trigger `checks` action `#759 <https://github.com/mergeability/mergeable/pull/759>`_
34
| June 20, 2024: fix: Respect all comments in lastComment validator and comment action `#755 <https://github.com/mergeability/mergeable/pull/755>`_
45
| June 12, 2024: feat: Support `issue_comment` event as trigger for actions `#754 <https://github.com/mergeability/mergeable/pull/754>`_
56
| June 10, 2024: fix: Docker image not working `#753 <https://github.com/mergeability/mergeable/pull/753>`_

lib/actions/checks.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ const createChecks = async (context, payload, actionObj) => {
1212
// Note: octokit (wrapped by probot) requires head_branch.
1313
// Contradicting API docs that only requires head_sha
1414
// --> https://developer.github.com/v3/checks/runs/#create-a-check-run
15-
if (context.payload.checksuite) {
16-
params.head_branch = context.payload.checksuite.head_branch
17-
params.head_sha = context.payload.checksuite.head_sha
15+
if (context.payload.check_suite) {
16+
params.head_branch = context.payload.check_suite.head_branch
17+
params.head_sha = context.payload.check_suite.head_sha
1818
} else if (context.eventName === 'issue_comment') {
1919
const issueNumber = context.payload.issue.number
2020
const pullRequest = (await actionObj.githubAPI.getPR(context, issueNumber)).data
@@ -104,6 +104,9 @@ class Checks extends Action {
104104
}
105105

106106
async beforeValidate (context, settings, name) {
107+
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
108+
return Promise.resolve()
109+
}
107110
const result = await createChecks(context, {
108111
status: 'in_progress',
109112
output: {
@@ -127,10 +130,16 @@ class Checks extends Action {
127130
}
128131

129132
async run ({ context, settings, payload }) {
133+
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
134+
return Promise.resolve()
135+
}
130136
await createChecks(context, payload, this)
131137
}
132138

133139
async afterValidate (context, settings, name, results) {
140+
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
141+
return Promise.resolve()
142+
}
134143
const checkRunResult = this.checkRunResult.get(name)
135144
const payload = settings.payload ? this.populatePayloadWithResult(settings.payload, results, context) : undefined
136145

lib/actions/merge.js

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class Merge extends Action {
4444
async beforeValidate () {}
4545

4646
async afterValidate (context, settings, name, results) {
47+
if (context.eventName === 'issue_comment' && !context.payload.issue?.pull_request) {
48+
return Promise.resolve()
49+
}
4750
if (settings.merge_method && !MERGE_METHOD_OPTIONS.includes(settings.merge_method)) {
4851
throw new UnSupportedSettingError(`Unknown Merge method, supported options are ${MERGE_METHOD_OPTIONS.join(', ')}`)
4952
}

0 commit comments

Comments
 (0)