diff --git a/README.md b/README.md index 0513ad5..151b5a9 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action/check-issue/README.md b/action/check-issue/README.md index fa78263..3acc857 100644 --- a/action/check-issue/README.md +++ b/action/check-issue/README.md @@ -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 @@ -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) | diff --git a/action/check-issue/action.yml b/action/check-issue/action.yml index f107107..03249d7 100644 --- a/action/check-issue/action.yml +++ b/action/check-issue/action.yml @@ -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 @@ -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 diff --git a/vouch/github.nu b/vouch/github.nu index 1161ab2..d85fff8 100644 --- a/vouch/github.nu +++ b/vouch/github.nu @@ -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 @@ -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 @@ -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) { @@ -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" } @@ -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" } @@ -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" } @@ -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" }