Skip to content

Commit 472496b

Browse files
authored
Merge pull request #9 from mainmatter/custom-bot-user
Allow custom bot username via config
2 parents 2b090c8 + d464994 commit 472496b

File tree

4 files changed

+11
-2
lines changed

4 files changed

+11
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,6 @@ If you do end up adding this action in a non-PR context then it is designed to j
8080

8181
**Required** Used to identify the test that has failed. Make sure that you are specific enough, which means that you probably should pass a matrix variable to this ID
8282

83+
### `bot-user`
84+
85+
**Optional** This is only used if you have a custom bot user whos name is different from the default `github-actions[bot]`. This is an advanced feature and should be ignored by most users

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ inputs:
77
description: 'Identifier of the test'
88
outcome:
99
description: 'The outcome of the job'
10+
bot-user:
11+
description: 'The username for the bot that posts the comment'
12+
required: false
13+
default: 'github-actions[bot]'
1014
runs:
1115
using: 'node16'
1216
main: 'dist/index.js'

dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9593,6 +9593,7 @@ if(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.eventName !== 'pull_requ
95939593
const myToken = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('repo-token', { required: true });
95949594
const outcome = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('outcome', { required: true });
95959595
const testId = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('test-id', { required: true });
9596+
const botUser = (0,_actions_core__WEBPACK_IMPORTED_MODULE_0__.getInput)('bot-user', { required: true });
95969597

95979598
if (outcome === 'failure') {
95989599
const octokit = (0,_actions_github__WEBPACK_IMPORTED_MODULE_1__.getOctokit)(myToken);
@@ -9604,7 +9605,7 @@ if(_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.eventName !== 'pull_requ
96049605
issue_number: pullRequest.number,
96059606
});
96069607

9607-
const existingComment = comments.find((comment) => comment.user.login === 'github-actions[bot]' && comment.body.endsWith(_lib_constants_js__WEBPACK_IMPORTED_MODULE_3__/* .signiture */ .o) && comment.body.includes(`sha: ${_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.sha}`));
9608+
const existingComment = comments.find((comment) => comment.user.login === botUser && comment.body.endsWith(_lib_constants_js__WEBPACK_IMPORTED_MODULE_3__/* .signiture */ .o) && comment.body.includes(`sha: ${_actions_github__WEBPACK_IMPORTED_MODULE_1__.context.sha}`));
96089609

96099610
if (existingComment) {
96109611

index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ if(context.eventName !== 'pull_request') {
1212
const myToken = getInput('repo-token', { required: true });
1313
const outcome = getInput('outcome', { required: true });
1414
const testId = getInput('test-id', { required: true });
15+
const botUser = getInput('bot-user', { required: true });
1516

1617
if (outcome === 'failure') {
1718
const octokit = getOctokit(myToken);
@@ -23,7 +24,7 @@ if(context.eventName !== 'pull_request') {
2324
issue_number: pullRequest.number,
2425
});
2526

26-
const existingComment = comments.find((comment) => comment.user.login === 'github-actions[bot]' && comment.body.endsWith(signiture) && comment.body.includes(`sha: ${context.sha}`));
27+
const existingComment = comments.find((comment) => comment.user.login === botUser && comment.body.endsWith(signiture) && comment.body.includes(`sha: ${context.sha}`));
2728

2829
if (existingComment) {
2930

0 commit comments

Comments
 (0)