Skip to content

Commit

Permalink
feat: add outputs comment-id
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Feb 19, 2021
1 parent 7f1aad2 commit 1fe9240
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## v1.2.0

- feat: add outputs `comment-id`.

## v1.1.0

- feat: add `number`.
Expand Down
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

![](https://img.shields.io/github/workflow/status/actions-cool/maintain-one-comment/CI?style=flat-square)
[![](https://img.shields.io/badge/marketplace-maintain--one--comment-blueviolet?style=flat-square)](https://github.com/marketplace/actions/maintain-one-comment)
[![](https://img.shields.io/github/v/release/actions-cool/maintain-one-comment?style=flat-square&color=orange)](https://github.com/actions-cool/maintain-one-comment/releases)

Maintain just one comment in Issue and PR.

Expand Down Expand Up @@ -41,6 +42,8 @@ jobs:
body-include: '<!-- Created by actions-cool/maintain-one-comment -->'
```
### Inputs
| Name | Desc | Type | Required |
| -- | -- | -- | -- |
| token | GitHub token | string | ✖ |
Expand All @@ -53,9 +56,14 @@ jobs:

- `number`: When no input, it will be the issue or PR number that triggered. When input, it is the highest priority

### Outputs

- `comment-id`: Return the ID of create or updated comment.
- About `comment-id` use, can refer: https://github.com/actions-cool/issues-helper

## Note

- When PR come from fork, it requires `pull_request_target`. When use `pull_request_target`, must [read](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target)
- When PR come from fork, it requires `pull_request_target` to comment (Reasons for github built-in permissions). When use `pull_request_target`, must [read](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target)

## Emoji List

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
body-include:
description: Comment body filter.

outputs:
comment-id:
description: 'Create or update comment ID'

runs:
using: 'node12'
main: 'dist/index.js'
2 changes: 2 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7113,6 +7113,7 @@ async function run() {
body,
});
core.info(`Actions: [create-comment][${body}] success!`);
core.setOutput('comment-id', data.id);

if (emojis) {
dealStringToArr(emojis).forEach(async item => {
Expand Down Expand Up @@ -7149,6 +7150,7 @@ async function run() {
}

await octokit.issues.updateComment(params);
core.setOutput('comment-id', commentId);
core.info(`Actions: [update-comment][${params.body}] success!`);
} else {
let length = comments.length;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "maintain-one-comment",
"version": "1.1.0",
"version": "1.2.0",
"private": true,
"description": "Maintain just one comment in Issue and PR.",
"main": "src/main.js",
Expand Down
2 changes: 2 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async function run() {
body,
});
core.info(`Actions: [create-comment][${body}] success!`);
core.setOutput('comment-id', data.id);

if (emojis) {
dealStringToArr(emojis).forEach(async item => {
Expand Down Expand Up @@ -105,6 +106,7 @@ async function run() {
}

await octokit.issues.updateComment(params);
core.setOutput('comment-id', commentId);
core.info(`Actions: [update-comment][${params.body}] success!`);
} else {
let length = comments.length;
Expand Down

0 comments on commit 1fe9240

Please sign in to comment.