Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: adjust require-permission default #51

Merged
merged 1 commit into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,12 @@ jobs:
| labels | Replace the labels of the issue | string | ✖ |
| contents | Add [reaction](#reactions-types) for this comment | string | ✖ |
| close-issue | Whether to close the issue at the same time | string | ✖ |
| require-permission | Permission required | string | ✖ |
| require-permission | Permission required, default is `write` | string | ✖ |

- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`. Block content contains `?`
- `labels`: Highest priority
- `close-issue`: Both `true` or `'true'` can take effect
- `require-permission`: When you do not input, there is no limit. Anyone comment will trigger. Optional values are `admin`, `write`, `read`, `none`
- `require-permission`: Optional values are `admin`, `write`, `read`, `none`
- If the team member sets the `read` permission, it is `read`
- If the external Collaborator is set to `read` permission, it is `read`
- Ordinary users have `read` permission
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -403,12 +403,12 @@ jobs:
| labels | 替换该 issue 的 labels | string | ✖ |
| contents | 为该评论的增加 [reaction](#reactions-types) | string | ✖ |
| close-issue | 是否同时关闭该 issue | string | ✖ |
| require-permission | 要求权限 | string | ✖ |
| require-permission | 要求权限,默认为 `write` | string | ✖ |

- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`。屏蔽内容包含 `?`
- `labels`:优先级最高
- `close-issue`:`true` 或 `'true'` 均可生效
- `require-permission`:当不输时,即无限制,任何人评论都会触发。可选值有 `admin`,`write`,`read`,`none`
- `require-permission`:可选值有 `admin`,`write`,`read`,`none`
- 团队成员若设置 `read` 权限,则为 `read`
- 外部 Collaborator 若设置 `read` 权限,则为 `read`
- 普通用户为 `read` 权限
Expand Down
22 changes: 10 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8020,7 +8020,7 @@ async function doMarkDuplicate(owner, repo, labels) {
const duplicateLabels = core.getInput('duplicate-labels');
const removeLables = core.getInput('remove-labels');
const closeIssue = core.getInput('close-issue');
const requirePermission = core.getInput('require-permission');
const requirePermission = core.getInput('require-permission') || 'write';

const commentId = context.payload.comment.id;
const commentBody = context.payload.comment.body;
Expand All @@ -8029,17 +8029,15 @@ async function doMarkDuplicate(owner, repo, labels) {

const ifCommandInput = !!duplicateCommand;

if (requirePermission) {
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}

if (
Expand Down
4 changes: 2 additions & 2 deletions docs/base.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ jobs:
| labels | Replace the labels of the issue | string | ✖ |
| contents | Add [reaction](/en-US/guide/ref#-reactions-type) for this comment | string | ✖ |
| close-issue | Whether to close the issue at the same time | string | ✖ |
| require-permission | Permission required | string | ✖ |
| require-permission | Permission required, default is `write` | string | ✖ |

- `duplicate-command`: When setting concise commands, while still supporting the original `Duplicate of`. Block content contains `?`
- `labels`: Highest priority
- `close-issue`: Both `true` or `'true'` can take effect
- `require-permission`: When you do not input, there is no limit. Anyone comment will trigger. Optional values are `admin`, `write`, `read`, `none`
- `require-permission`: Optional values are `admin`, `write`, `read`, `none`
- If the team member sets the `read` permission, it is `read`
- If the external Collaborator is set to `read` permission, it is `read`
- Ordinary users have `read` permission
Expand Down
4 changes: 2 additions & 2 deletions docs/base.md
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,12 @@ jobs:
| labels | 替换该 issue 的 labels | string | ✖ |
| contents | 为该评论的增加 [reaction](/guide/ref#-reactions-类型) | string | ✖ |
| close-issue | 是否同时关闭该 issue | string | ✖ |
| require-permission | 要求权限 | string | ✖ |
| require-permission | 要求权限,默认为 `write` | string | ✖ |

- `duplicate-command`:当设置简洁命令时,同时仍支持原有 `Duplicate of`。屏蔽内容包含 `?`
- `labels`:优先级最高
- `close-issue`:`true` 或 `'true'` 均可生效
- `require-permission`:当不输时,即无限制,任何人评论都会触发。可选值有 `admin`,`write`,`read`,`none`
- `require-permission`:可选值有 `admin`,`write`,`read`,`none`
- 团队成员若设置 `read` 权限,则为 `read`
- 外部 Collaborator 若设置 `read` 权限,则为 `read`
- 普通用户为 `read` 权限
Expand Down
22 changes: 10 additions & 12 deletions src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ async function doMarkDuplicate(owner, repo, labels) {
const duplicateLabels = core.getInput('duplicate-labels');
const removeLables = core.getInput('remove-labels');
const closeIssue = core.getInput('close-issue');
const requirePermission = core.getInput('require-permission');
const requirePermission = core.getInput('require-permission') || 'write';

const commentId = context.payload.comment.id;
const commentBody = context.payload.comment.body;
Expand All @@ -166,17 +166,15 @@ async function doMarkDuplicate(owner, repo, labels) {

const ifCommandInput = !!duplicateCommand;

if (requirePermission) {
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}
const res = await octokit.repos.getCollaboratorPermissionLevel({
owner,
repo,
username: commentUser,
});
const { permission } = res.data;
if (!checkPermission(requirePermission, permission)) {
core.info(`The user ${commentUser} is not allow!`);
return false;
}

if (
Expand Down