Skip to content

Commit 91c013f

Browse files
committed
feat(test/label): add post-comment input to control PR commenting
Add a `post-comment` input (default: `true`, not required) to both `test/label/done/added` and `test/label/done/remove` actions. When set to `false`, all PR comment posting is skipped while label logic runs unchanged.
1 parent 53060b2 commit 91c013f

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

test/label/done/added/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
description: 'Name of the test type used in comments (e.g. Robot)'
1515
required: false
1616
default: 'Test'
17+
post-comment:
18+
description: 'Whether to post a comment on the PR'
19+
required: false
20+
default: 'true'
1721
token:
1822
description: 'GitHub token or PAT used to post comments (defaults to github.token)'
1923
required: false
@@ -34,13 +38,15 @@ runs:
3438
const repo = context.repo;
3539
3640
const postComment = async (body) => {
41+
if (!postCommentEnabled) { core.info('post-comment is disabled. Skipping comment.'); return; }
3742
try {
3843
await github.rest.issues.createComment({ ...repo, issue_number: pr, body });
3944
} catch (err) {
4045
core.warning(`Could not post comment: ${err.message}`);
4146
}
4247
};
4348
49+
const postCommentEnabled = '${{ inputs.post-comment }}' !== 'false';
4450
const { data: labels } = await github.rest.issues.listLabelsOnIssue({ ...repo, issue_number: pr });
4551
const has = new Set(labels.map(l => l.name));
4652
const shaLine = sha ? `\n\n**Commit:** \`${sha}\`` : '';

test/label/done/remove/action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ inputs:
1414
description: 'Name of the test type used in comments (e.g. Robot)'
1515
required: false
1616
default: 'Test'
17+
post-comment:
18+
description: 'Whether to post a comment on the PR'
19+
required: false
20+
default: 'true'
1721
token:
1822
description: 'GitHub token or PAT used to remove labels and post comments (defaults to github.token)'
1923
required: false
@@ -34,13 +38,15 @@ runs:
3438
const repo = context.repo;
3539
3640
const postComment = async (body) => {
41+
if (!postCommentEnabled) { core.info('post-comment is disabled. Skipping comment.'); return; }
3742
try {
3843
await github.rest.issues.createComment({ ...repo, issue_number: pr, body });
3944
} catch (err) {
4045
core.warning(`Could not post comment: ${err.message}`);
4146
}
4247
};
4348
49+
const postCommentEnabled = '${{ inputs.post-comment }}' !== 'false';
4450
const { data: labels } = await github.rest.issues.listLabelsOnIssue({ ...repo, issue_number: pr });
4551
const has = new Set(labels.map(l => l.name));
4652

0 commit comments

Comments
 (0)