Skip to content

Commit

Permalink
feat(prs): add new input pull-request-remove-labels-after-close
Browse files Browse the repository at this point in the history
When closing a pull request, you can now remove some extra labels.
This might specifically handy if you want to remove the stale label to "clean" the closed pull request.
Closes #859.
  • Loading branch information
C0ZEN committed Sep 4, 2022
1 parent 7d8e170 commit 87e990b
Show file tree
Hide file tree
Showing 22 changed files with 1,001 additions and 83 deletions.
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ To help us have a clear vision over the workflow and also for you if you are jus
- When the input value is not empty, add a comment
- Check if the action should also add extra labels (coming from the `pull-request-add-labels-after-close` input)
- When the input value is filled list, add the listed labels
- Check if the action should also remove extra labels (coming from the `pull-request-remove-labels-after-close` input)
- When the input value is filled list, remove the listed labels
- Check if the action should also delete the branch (coming from the `pull-request-delete-branch-after-close` input)
- When the input value is true, delete the branch
- Check if the pull request last update is older than X days (coming from the `pull-request-days-before-stale`)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ All the inputs that are used both for issues and pull requests.
| [pull-request-add-labels-after-stale](https://sonia-stale-action.vercel.app/docs/pull-requests/inputs/pull-request-add-labels-after-stale-input) | A list of labels added when the processing stale the pull request (multiline). | |
| [pull-request-remove-labels-after-stale](https://sonia-stale-action.vercel.app/docs/pull-requests/inputs/pull-request-remove-labels-after-stale-input) | A list of labels removed when the processing stale the pull request (multiline). | |
| [pull-request-add-labels-after-close](https://sonia-stale-action.vercel.app/docs/pull-requests/inputs/pull-request-add-labels-after-close-input) | A list of labels added when the processing close the pull request (multiline). | |
| [pull-request-remove-labels-after-close](https://sonia-stale-action.vercel.app/docs/pull-requests/inputs/pull-request-remove-labels-after-close-input) | A list of labels removed when the processing close the pull request (multiline). | |
| [pull-request-to-draft-instead-of-stale](https://sonia-stale-action.vercel.app/docs/pull-requests/inputs/pull-request-to-draft-instead-of-stale-input) | Convert the pull request to a draft pull request instead of handling it as a stale candidate. | `false` |
| [pull-request-delete-branch-after-close](https://sonia-stale-action.vercel.app/docs/pull-requests/inputs/pull-request-delete-branch-after-close-input) | Delete the branch when the processing close the pull request. | `false` |

Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ inputs:
description: 'A list of labels added when the processing close the pull request (multiline).'
required: false
default: ''
pull-request-remove-labels-after-close:
description: 'A list of labels removed when the processing close the pull request (multiline).'
required: false
default: ''
pull-request-to-draft-instead-of-stale:
description: 'Convert the pull request to a draft pull request instead of handling it as a stale candidate.'
required: false
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions documentation/docs/03-all-inputs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ The list of all the inputs.
| [pull-request-add-labels-after-stale](pull-requests/inputs/pull-request-add-labels-after-stale-input) | A list of labels added when the processing stale the pull request (multiline). | |
| [pull-request-remove-labels-after-stale](pull-requests/inputs/pull-request-remove-labels-after-stale-input) | A list of labels removed when the processing stale the pull request (multiline). | |
| [pull-request-add-labels-after-close](pull-requests/inputs/pull-request-add-labels-after-close-input) | A list of labels added when the processing close the pull request (multiline). | |
| [pull-request-remove-labels-after-close](pull-requests/inputs/pull-request-remove-labels-after-close-input) | A list of labels removed when the processing close the pull request (multiline). | |
| [pull-request-to-draft-instead-of-stale](pull-requests/inputs/pull-request-to-draft-instead-of-stale-input) | Convert the pull request to a draft pull request instead of handling it as a stale candidate. | `false` |
| [pull-request-delete-branch-after-close](pull-requests/inputs/pull-request-delete-branch-after-close-input) | Delete the branch when the processing close the pull request. | `false` |
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,6 @@ The list of all the pull requests inputs.
| [pull-request-add-labels-after-stale](pull-request-add-labels-after-stale-input) | A list of labels added when the processing stale the pull request (multiline). | |
| [pull-request-remove-labels-after-stale](pull-request-remove-labels-after-stale-input) | A list of labels removed when the processing stale the pull request (multiline). | |
| [pull-request-add-labels-after-close](pull-request-add-labels-after-close-input) | A list of labels added when the processing close the pull request (multiline). | |
| [pull-request-remove-labels-after-close](pull-request-remove-labels-after-close-input) | A list of labels removed when the processing close the pull request (multiline). | |
| [pull-request-to-draft-instead-of-stale](pull-request-to-draft-instead-of-stale-input) | Convert the pull request to a draft pull request instead of handling it as a stale candidate. | `false` |
| [pull-request-delete-branch-after-close](pull-request-delete-branch-after-close-input) | Delete the branch when the processing close the pull request. | `false` |
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ This can be useful if you wish to improve the communication and the process on h

:::note

You can also add labels onto it by using the [add labels after close input](pull-request-add-labels-after-close-input)
You can also add labels onto it by using the [add labels after close input](pull-request-add-labels-after-close-input),
remove labels onto it by using the [remove labels after close input](pull-request-remove-labels-after-close-input)
and define the number of days before closing it by using the [days before close input](pull-request-days-before-close-input).

:::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ The pull request will be closed tomorrow if no update occur until then.

:::info

You can also add labels onto it by using the [add labels after close input](pull-request-add-labels-after-close-input)
You can also add labels onto it by using the [add labels after close input](pull-request-add-labels-after-close-input),
remove labels onto it by using the [remove labels after close input](pull-request-remove-labels-after-close-input)
and add a comment to explain why it was closed by using the [close comment input](pull-request-close-comment-input).

:::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ If not, the GitHub API will throw an error.

:::info

You can also add a comment to explain why it was closed by using the [close comment input](pull-request-close-comment-input)
You can also add a comment to explain why it was closed by using the [close comment input](pull-request-close-comment-input),
remove labels onto it by using the [remove labels after close input](pull-request-remove-labels-after-close-input)
and define the number of days before closing it by using the [days before close input](pull-request-days-before-close-input).

:::
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
id: pull-request-remove-labels-after-close-input
title: Remove pull request labels after close input
description: |
All the information you need to know about the remove pull request labels after close input.
Including a detailed description and an example.
tags:
- Pull requests
- Inputs
- Labels
- Closing
---

### Input {#input}

Name: `pull-request-remove-labels-after-close`
Type: `string[]`
Default value: `[]`

### Description {#description}

This input will let you remove extra labels when the processing close the pull requests.
This can be useful if you wish to easily remove extra labels to improve your triage post-closing.

:::caution

The labels must be real labels, existing inside your repository list of labels (_github.com/your-organization/your-repository/labels_).
If not, the GitHub API will throw an error.

:::

:::info

You can also add a comment to explain why it was closed by using the [close comment input](pull-request-close-comment-input),
add labels onto it by using the [add labels after close input](pull-request-add-labels-after-close-input)
and define the number of days before closing it by using the [days before close input](pull-request-days-before-close-input).

:::

### Example {#example}

```yml {6-8}
# ...
name: Stale
id: stale
uses: sonia-corporation/stale@latest
with:
pull-request-remove-labels-after-close: |
new author feedback
closing soon!
```
1 change: 1 addition & 0 deletions src/core/inputs/inputs.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export enum EInputs {
PULL_REQUEST_ADD_LABELS_AFTER_CLOSE = `pull-request-add-labels-after-close`,
PULL_REQUEST_ADD_LABELS_AFTER_STALE = `pull-request-add-labels-after-stale`,
PULL_REQUEST_REMOVE_LABELS_AFTER_STALE = `pull-request-remove-labels-after-stale`,
PULL_REQUEST_REMOVE_LABELS_AFTER_CLOSE = `pull-request-remove-labels-after-close`,
PULL_REQUEST_CLOSE_COMMENT = `pull-request-close-comment`,
PULL_REQUEST_DAYS_BEFORE_CLOSE = `pull-request-days-before-close`,
PULL_REQUEST_DAYS_BEFORE_STALE = `pull-request-days-before-stale`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface IPullRequestsInputs extends IInputs {
readonly pullRequestOnlyWithMilestones: boolean;
readonly pullRequestOnlyWithProjectCards: boolean;
readonly pullRequestProcessing: boolean;
readonly pullRequestRemoveLabelsAfterClose: string[];
readonly pullRequestRemoveLabelsAfterStale: string[];
readonly pullRequestStaleComment: IComment | '';
readonly pullRequestStaleLabel: string;
Expand Down
Loading

0 comments on commit 87e990b

Please sign in to comment.