Skip to content

Commit

Permalink
feat: add comment-mark
Browse files Browse the repository at this point in the history
  • Loading branch information
xrkffgg committed Apr 17, 2022
1 parent 6140415 commit 8e9fa3e
Showing 5 changed files with 29 additions and 9 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v1.5.0

`2022.04.17`

- feat: add `comment-mark`.

## v1.4.0

`2022.01.04`
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -43,6 +43,7 @@ jobs:
| skip-verify-authority | Skip verify by creator authority. Option: `read` `write` `admin` | string | ✖ |
| skip-verify-users | Skip verify by creator userid. Support multiple | string | ✖ |
| comment | Comment when verification success | string | ✖ |
| comment-mark | Comment mark to find. | string | ✖ |
| assignees | Assignees when verification success | string | ✖ |
| close | Close PR when verification success | boolean | ✖ |
| set-failed | When hit, whether set failed. Default true | boolean | ✖ |
4 changes: 2 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -4,8 +4,6 @@ description: 'Verify PR files modification.'
author: 'xrkffgg'

branding:
# https://feathericons.com
# e.g. https://haya14busa.github.io/github-action-brandings
icon: 'align-justify'
color: 'red'

@@ -28,6 +26,8 @@ inputs:
description: Allowed paths.
comment:
description: Comment when verification success.
comment-mark:
description: Comment mark to find.
assignees:
description: Assignees when verification success.
close:
15 changes: 11 additions & 4 deletions dist/index.js
Original file line number Diff line number Diff line change
@@ -9714,8 +9714,9 @@ const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
const context = github.context;

const FIXED = '<!-- Created by actions-cool/verify-files-modify. Do not remove. -->';
const InfoMessage = 'You have modified a disabled file or paths, please check! See .github/Workflows/verify-files-modify.yml';
const FIXED = 'Created by actions-cool/verify-files-modify. Do not remove.';
const InfoMessage =
'You have modified a disabled file or paths, please check! See .github/Workflows/verify-files-modify.yml';

// *****************************************
async function run() {
@@ -9735,6 +9736,7 @@ async function run() {
}

const comment = core.getInput('comment');
const commentMark = core.getInput('comment-mark');
const assignees = core.getInput('assignees');
const close = core.getInput('close');

@@ -9814,16 +9816,21 @@ async function run() {
issue_number: number,
});

let commentFixed = `<!-- ${FIXED} -->`;
if (commentMark) {
commentFixed = `<!-- ${FIXED} ${commentMark} -->`;
}

const commentsArr = commentData.data;
for (let i = 0; i < commentsArr.length; i++) {
if (commentsArr[i].body.includes(FIXED)) {
if (commentsArr[i].body.includes(commentFixed)) {
ifHasComment = true;
commentId = commentsArr[i].id;
break;
}
}

const body = `${comment}\n\n${FIXED}`;
const body = `${comment}\n\n${commentFixed}`;

if (comment && ifHasComment) {
await octokit.issues.updateComment({
12 changes: 9 additions & 3 deletions src/main.js
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ const token = core.getInput('token');
const octokit = new Octokit({ auth: `token ${token}` });
const context = github.context;

const FIXED = '<!-- Created by actions-cool/verify-files-modify. Do not remove. -->';
const FIXED = 'Created by actions-cool/verify-files-modify. Do not remove.';
const InfoMessage =
'You have modified a disabled file or paths, please check! See .github/Workflows/verify-files-modify.yml';

@@ -32,6 +32,7 @@ async function run() {
}

const comment = core.getInput('comment');
const commentMark = core.getInput('comment-mark');
const assignees = core.getInput('assignees');
const close = core.getInput('close');

@@ -111,16 +112,21 @@ async function run() {
issue_number: number,
});

let commentFixed = `<!-- ${FIXED} -->`;
if (commentMark) {
commentFixed = `<!-- ${FIXED} ${commentMark} -->`;
}

const commentsArr = commentData.data;
for (let i = 0; i < commentsArr.length; i++) {
if (commentsArr[i].body.includes(FIXED)) {
if (commentsArr[i].body.includes(commentFixed)) {
ifHasComment = true;
commentId = commentsArr[i].id;
break;
}
}

const body = `${comment}\n\n${FIXED}`;
const body = `${comment}\n\n${commentFixed}`;

if (comment && ifHasComment) {
await octokit.issues.updateComment({

0 comments on commit 8e9fa3e

Please sign in to comment.