Skip to content

Commit 5f247e0

Browse files
authoredApr 4, 2022
github-actions-bot: Fix collapsing of unrelated comments (#3525)
1 parent faa42e2 commit 5f247e0

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed
 

‎.github/workflows/github-actions-bot.yml

+18-15
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,15 @@ on:
1212
- PullRequestOpened
1313
types:
1414
- completed
15+
env:
16+
SUPPORTED_COMMANDS: |
17+
<details>
18+
<summary> Supported commands </summary>
19+
20+
Please post this commands in separate comments and only one per comment:
21+
* `@github-actions run-benchmark` - Run benchmark comparing base and merge commits for this PR
22+
* `@github-actions publish-pr-on-npm` - Build package from this PR and publish it on NPM
23+
</details>
1524
jobs:
1625
hello-message:
1726
if: github.event_name == 'workflow_run'
@@ -38,15 +47,6 @@ jobs:
3847
`Hi @${event.sender.login}, I'm @github-actions bot happy to help you with this PR 👋\n\n` +
3948
process.env.SUPPORTED_COMMANDS,
4049
})
41-
env:
42-
SUPPORTED_COMMANDS: |
43-
<details>
44-
<summary> Supported commands </summary>
45-
46-
Please post this commands in separate comments and only one per comment:
47-
* `@github-actions run-benchmark` - Run benchmark comparing base and merge commits for this PR
48-
* `@github-actions publish-pr-on-npm` - Build package from this PR and publish it on NPM
49-
</details>
5050
5151
accept-cmd:
5252
if: |
@@ -94,9 +94,10 @@ jobs:
9494

9595
respond-to-cmd:
9696
needs:
97+
- accept-cmd
9798
- cmd-publish-pr-on-npm
9899
- cmd-run-benchmark
99-
if: github.event_name == 'issue_comment' && always()
100+
if: needs.accept-cmd.result != 'skipped' && always()
100101
runs-on: ubuntu-latest
101102
steps:
102103
- uses: actions/github-script@v5
@@ -107,15 +108,17 @@ jobs:
107108
108109
let replyMessage;
109110
let allSkipped = true;
110-
for (const { result, outputs } of Object.values(needs)) {
111-
allSkipped = allSkipped && result === 'skipped';
112-
replyMessage = replyMessage || outputs.replyMessage;
111+
for (const [ name, job ] of Object.entries(needs)) {
112+
if (name.startsWith('cmd-')) {
113+
allSkipped = allSkipped && job.result === 'skipped';
114+
}
115+
replyMessage = replyMessage || job.outputs.replyMessage;
113116
}
114117
115118
if (!replyMessage) {
116119
replyMessage = allSkipped
117-
? 'Unknown command, please check help message at the top of PR.'
118-
: `Something went wrong, please check logs here:\n${process.env.RUN_URL}`;
120+
? 'Unknown command 😕\n\n' + process.env.SUPPORTED_COMMANDS
121+
: `Something went wrong, [please check log](${process.env.RUN_URL}).`;
119122
}
120123
121124
const quoteRequest = comment.body

0 commit comments

Comments
 (0)
Please sign in to comment.