Skip to content
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
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ For an example, look at this repository! It fully integrates vouch.
Below is a list of the actions and a brief description of their function.
See the linked README in the action directory for full usage details.

| Action | Trigger | Description |
| ------------------------------------------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| [check-issue](action/check-issue/README.md) | `issues` | Check if an issue author is vouched on open or reopen. Bots and collaborators with write access are automatically allowed. Optionally auto-close issues from unvouched or denounced users. |
| [check-pr](action/check-pr/README.md) | `pull_request_target` | Check if a PR author is vouched on open or reopen. Bots and collaborators with write access are automatically allowed. Optionally auto-close PRs from unvouched or denounced users. |
| [check-user](action/check-user/README.md) | Any | Check if a GitHub user is vouched. Outputs the user's status and fails the step by default if the user is not vouched. Set `allow-fail` to only report via output. |
| [manage-by-discussion](action/manage-by-discussion/README.md) | `discussion_comment` | Let collaborators vouch, denounce, or unvouch users via discussion comments. Updates the vouched file and commits the change. |
| [manage-by-issue](action/manage-by-issue/README.md) | `issue_comment` | Let collaborators vouch or denounce users via issue comments. Updates the vouched file and commits the change. |
| [sync-codeowners](action/sync-codeowners/README.md) | Any | Sync CODEOWNERS owners into the vouch list by vouching missing users. |
| [setup-vouch](action/setup-vouch/README.md) | Any | Install the `vouch` CLI on `PATH`. Nushell is installed automatically if not already available. |
| Action | Trigger | Description |
| ------------------------------------------------------------- | --------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [check-issue](action/check-issue/README.md) | `issues` | Check if an issue author is vouched on open or reopen. Bots and collaborators with write access are automatically allowed. Optionally auto-close and lock issues from unvouched or denounced users. |
| [check-pr](action/check-pr/README.md) | `pull_request_target` | Check if a PR author is vouched on open or reopen. Bots and collaborators with write access are automatically allowed. Optionally auto-close PRs from unvouched or denounced users. |
| [check-user](action/check-user/README.md) | Any | Check if a GitHub user is vouched. Outputs the user's status and fails the step by default if the user is not vouched. Set `allow-fail` to only report via output. |
| [manage-by-discussion](action/manage-by-discussion/README.md) | `discussion_comment` | Let collaborators vouch, denounce, or unvouch users via discussion comments. Updates the vouched file and commits the change. |
| [manage-by-issue](action/manage-by-issue/README.md) | `issue_comment` | Let collaborators vouch or denounce users via issue comments. Updates the vouched file and commits the change. |
| [sync-codeowners](action/sync-codeowners/README.md) | Any | Sync CODEOWNERS owners into the vouch list by vouching missing users. |
| [setup-vouch](action/setup-vouch/README.md) | Any | Install the `vouch` CLI on `PATH`. Nushell is installed automatically if not already available. |

### CLI

Expand Down
4 changes: 3 additions & 1 deletion action/check-issue/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Check if an issue author is a vouched contributor. Bots and
collaborators with write access are automatically allowed. Denounced
users are always blocked. When `require-vouch` is true (default),
unvouched users are also blocked. Use `auto-close` to close issues
from blocked users.
from blocked users. When `auto-lock` is true, closed issues are also
locked to prevent further comments.

## Usage

Expand Down Expand Up @@ -35,6 +36,7 @@ jobs:
| --------------- | -------- | ---------------------- | ------------------------------------------------------------ |
| `issue-number` | Yes | | GitHub issue number |
| `auto-close` | No | `"false"` | Automatically close issues from unvouched or denounced users |
| `auto-lock` | No | `"false"` | Automatically lock issues after closing |
| `dry-run` | No | `"false"` | Print what would happen without making changes |
| `repo` | No | Current repository | Repository in `owner/repo` format |
| `require-vouch` | No | `"true"` | Require users to be vouched (false = only block denounced) |
Expand Down
5 changes: 5 additions & 0 deletions action/check-issue/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ inputs:
description: "Automatically close issues from unvouched or denounced users."
required: false
default: "false"
auto-lock:
description: "Automatically lock issues after closing."
required: false
default: "false"
dry-run:
description: "Print what would happen without making changes."
required: false
Expand Down Expand Up @@ -59,6 +63,7 @@ runs:
--template-file "${{ inputs.template-file }}"
--require-vouch=${{ inputs.require-vouch }}
--auto-close=${{ inputs.auto-close }}
--auto-lock=${{ inputs.auto-lock }}
--dry-run=${{ inputs.dry-run }}
)
$"status=($status)" | save --append $env.GITHUB_OUTPUT
23 changes: 21 additions & 2 deletions vouch/github.nu
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ export def gh-check-pr [
# When --require-vouch is false, only denounced users are blocked.
#
# When --auto-close is true and user is unvouched/denounced, the issue is closed.
# When --auto-lock is true, the issue is also locked after closing.
#
# --template-file can be used to supply a path to a custom template, which
# follows the string convention as seen in Nushell's "format pattern". Note the
Expand All @@ -176,6 +177,7 @@ export def gh-check-pr [
# Outputs status: "skipped" (bot), "vouched", "allowed", or "closed".
@example "Check issue author status (dry run)" { ./vouch.nu gh-check-issue 123 }
@example "Auto-close unvouched issues" { ./vouch.nu gh-check-issue 123 --auto-close --dry-run=false }
@example "Auto-close and lock" { ./vouch.nu gh-check-issue 123 --auto-close --auto-lock --dry-run=false }
@example "Allow unvouched users, only block denounced" { ./vouch.nu gh-check-issue 123 --require-vouch=false --auto-close }
export def gh-check-issue [
issue_number: int, # GitHub issue number
Expand All @@ -185,6 +187,7 @@ export def gh-check-issue [
--template-file: string = $issue_template, # Optional path to response template to use for unvouched users
--require-vouch = true, # Require users to be vouched (false = only block denounced)
--auto-close = false, # Automatically close issues from unvouched/denounced users
--auto-lock = false, # Automatically lock issues after closing
--dry-run = true, # Print what would happen without making changes
] {
if ($repo | is-empty) {
Expand Down Expand Up @@ -234,7 +237,11 @@ export def gh-check-issue [
let message = "This issue has been automatically closed because the author is explicitly blocked in the vouch list."

if $dry_run {
print "(dry-run) Would post comment and close issue"
if $auto_lock {
print "(dry-run) Would post comment, close, and lock issue"
} else {
print "(dry-run) Would post comment and close issue"
}
return "closed"
}

Expand All @@ -247,6 +254,10 @@ export def gh-check-issue [
state_reason: "not_planned",
}

if $auto_lock {
api "put" $"/repos/($owner)/($repo_name)/issues/($issue_number)/lock" {}
}

return "closed"
}

Expand All @@ -271,7 +282,11 @@ export def gh-check-issue [
} | template render (if ($template_file | is-not-empty) { $template_file } else $issue_template)

if $dry_run {
print "(dry-run) Would post comment and close issue"
if $auto_lock {
print "(dry-run) Would post comment, close, and lock issue"
} else {
print "(dry-run) Would post comment and close issue"
}
return "closed"
}

Expand All @@ -284,6 +299,10 @@ export def gh-check-issue [
state_reason: "not_planned",
}

if $auto_lock {
api "put" $"/repos/($owner)/($repo_name)/issues/($issue_number)/lock" {}
}

return "closed"
}

Expand Down