Skip to content

Commit 255b3a0

Browse files
committed
- fixed comment prefix usage
1 parent 8b4265b commit 255b3a0

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

index.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -267,14 +267,15 @@ module.exports = (app) => {
267267
app.on(
268268
"issue_comment.created",
269269
async (context) => {
270-
const command = '\deploy'
270+
const commandRegex = /^[\\\|\/\#]deploy([^$]+)$/;
271271
const {
272272
comment: { body: comment },
273273
repository: { owner: { login: owner }, name: repo },
274274
} = context.payload;
275+
let matched;
275276
if (
276277
!comment ||
277-
comment.indexOf(command) === -1
278+
!(matched = comment.toLowerCase().match(commandRegex))
278279
) {
279280
app.log.info(`Missing comment body or comment doesn't start with /deploy message`);
280281
return;
@@ -292,10 +293,8 @@ module.exports = (app) => {
292293
return;
293294
}
294295

295-
const components = context.payload.comment.body
296-
.toLowerCase()
297-
.substr(command.length)
298-
.split(' ')
296+
const components = matched[1]
297+
.split(/\s|\n/)
299298
.filter(Boolean)
300299
.map((component) => {
301300
const parts = component.split(':');
@@ -332,7 +331,7 @@ module.exports = (app) => {
332331
}
333332

334333
const payloads = await getDeployPayloads(
335-
context, { owner, repo, pullNumber, sha }, [],'push',
334+
context, { owner, repo, pullNumber, sha }, [],'push', app.log,
336335
);
337336
await createDeployments(app, context, owner, payloads);
338337
},
@@ -356,7 +355,7 @@ module.exports = (app) => {
356355

357356
if (['opened', 'reopened'].includes(action)) {
358357
const payloads = await getDeployPayloads(
359-
context, { owner, repo, pullNumber }, [],'pull_request',
358+
context, { owner, repo, pullNumber }, [],'pull_request', app.log,
360359
);
361360
await createDeployments(app, context, owner, payloads);
362361
}

0 commit comments

Comments
 (0)