Skip to content

Commit b193b90

Browse files
Make environment optional
If `/deploy` is the only comment, assume deploying to `dev`.
1 parent 6b267a1 commit b193b90

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

.github/workflows/deploy.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,15 @@ jobs:
6060
throw new Error(`Error: @${username} is not a repository collaborator.`);
6161
}
6262
63-
const regex = /\/deploy ([a-zA-Z\d\-\_]+)/;
64-
const arguments = regex.exec(context.payload.comment.body);
63+
const comment = context.payload.comment.body;
64+
const regex = /^\/deploy(\s+([a-zA-Z\d\-\_]+))?\s*$/;
65+
const arguments = regex.exec(comment);
6566
66-
if (arguments === null || arguments.length < 2) {
67-
throw new Error('Invalid command');
67+
if (!arguments || arguments.length < 1) {
68+
throw new Error(`Invalid command: ${comment}`);
6869
}
6970
70-
const environment = arguments[1].trim();
71-
return environment;
71+
return arguments[2] || 'dev';
7272
7373
- name: 'Find run for #${{ github.event.issue.number }}'
7474
uses: actions/github-script@v7

0 commit comments

Comments
 (0)