Skip to content

Commit 23a59fe

Browse files
committed
feat: add comment-body output
1 parent f384866 commit 23a59fe

4 files changed

Lines changed: 58 additions & 11 deletions

File tree

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ inputs:
5050
description: 'The column and direction to sort the results by. The format is "column:direction", where column is one of "Filename", "Size", or "Change" and direction is "asc" or "desc". For example, "Size:desc" sorts the table by file size in descending order.'
5151
default: 'Filename:asc'
5252

53+
outputs:
54+
comment-body:
55+
description: 'The full Markdown body the action posts to the PR, including the size report, footer, and hidden marker comment: "<!-- compressed-size-action -->" or "<!-- compressed-size-action::KEY -->" when comment-key is set.'
56+
5357
runs:
5458
using: 'node24'
5559
main: 'index.js'

package-lock.json

Lines changed: 48 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
},
99
"license": "MIT",
1010
"devDependencies": {
11-
"@actions/core": "^1.2.6",
11+
"@actions/core": "^1.10.0",
1212
"@actions/exec": "^1.0.4",
1313
"@actions/github": "^4.0.0",
1414
"@babel/core": "^7.29.0",

src/index.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getInput, setFailed, startGroup, endGroup, debug } from '@actions/core';
1+
import { getInput, setFailed, setOutput, startGroup, endGroup, debug } from '@actions/core';
22
import { context, getOctokit } from '@actions/github';
33
import { exec } from '@actions/exec';
44
import { SizePlugin } from '@rschristian/size-plugin';
@@ -167,9 +167,12 @@ async function run(octokit, context, token) {
167167
...commentInfo,
168168
body:
169169
markdownDiff +
170-
`\n\n<a href="https://github.com/preactjs/compressed-size-action"><sub>compressed-size-action${commentKey ? `::${commentKey}` : ''}</sub></a>`
170+
`\n\n<a href="https://github.com/preactjs/compressed-size-action"><sub>compressed-size-action${commentKey ? `::${commentKey}` : ''}</sub></a>` +
171+
`\n<!-- compressed-size-action${commentKey ? `::${commentKey}` : ''} -->`
171172
};
172173

174+
setOutput('comment-body', comment.body);
175+
173176
if (context.eventName !== 'pull_request' && context.eventName !== 'pull_request_target') {
174177
console.log('No PR associated with this action run. Not posting a check or comment.');
175178
outputRawMarkdown = false;

0 commit comments

Comments
 (0)