Skip to content

Commit

Permalink
feat: add new filtering and labeling options, update input parameter …
Browse files Browse the repository at this point in the history
…names

BREAKING CHANGE: input parameter names have changed
  • Loading branch information
dessant committed Sep 27, 2021
1 parent a0c7da3 commit 26fd836
Show file tree
Hide file tree
Showing 4 changed files with 503 additions and 181 deletions.
231 changes: 189 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ please consider contributing with

## Usage

Create a `lock.yml` workflow file in the `.github/workflows` directory,
Create the `lock.yml` workflow file in the `.github/workflows` directory,
use one of the [example workflows](#examples) to get started.

### Inputs
Expand All @@ -28,44 +28,118 @@ The action can be configured using [input parameters](https://docs.github.com/en
- GitHub access token, value must be `${{ github.token }}` or an encrypted
secret that contains a [personal access token](#using-a-personal-access-token)
- Optional, defaults to `${{ github.token }}`
- **`issue-lock-inactive-days`**
- **`issue-inactive-days`**
- Number of days of inactivity before a closed issue is locked
- Optional, defaults to `365`
- **`issue-exclude-created-before`**
- Do not lock issues created before a given timestamp,
- **`exclude-issue-created-before`**
- Do not lock issues created before a given date,
value must follow ISO 8601, ignored
when `exclude-issue-created-between` is set
- Optional, defaults to `''`
- **`exclude-issue-created-after`**
- Do not lock issues created after a given date,
value must follow ISO 8601, ignored
when `exclude-issue-created-between` is set
- Optional, defaults to `''`
- **`exclude-issue-created-between`**
- Do not lock issues created in a given time interval,
value must follow ISO 8601
- Optional, defaults to `''`
- **`issue-exclude-labels`**
- Do not lock issues with these labels, value must be
- **`exclude-issue-closed-before`**
- Do not lock issues closed before a given date,
value must follow ISO 8601, ignored
when `exclude-issue-closed-between` is set
- Optional, defaults to `''`
- **`exclude-issue-closed-after`**
- Do not lock issues closed after a given date,
value must follow ISO 8601, ignored
when `exclude-issue-closed-between` is set
- Optional, defaults to `''`
- **`exclude-issue-closed-between`**
- Do not lock issues closed in a given time interval,
value must follow ISO 8601
- Optional, defaults to `''`
- **`include-any-issue-labels`**
- Only lock issues with any of these labels, value must be
a comma separated list of labels or `''`, ignored
when `include-all-issue-labels` is set
- Optional, defaults to `''`
- **`include-all-issue-labels`**
- Only lock issues with all these labels, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`issue-lock-labels`**
- **`exclude-any-issue-labels`**
- Do not lock issues with any of these labels, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`add-issue-labels`**
- Labels to add before locking an issue, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`issue-lock-comment`**
- **`remove-issue-labels`**
- Labels to remove before locking an issue, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`issue-comment`**
- Comment to post before locking an issue
- Optional, defaults to `''`
- **`issue-lock-reason`**
- Reason for locking an issue, value must be one
of `resolved`, `off-topic`, `too heated`, `spam` or `''`
- Optional, defaults to `resolved`
- **`pr-lock-inactive-days`**
- **`pr-inactive-days`**
- Number of days of inactivity before a closed pull request is locked
- Optional, defaults to `365`
- **`pr-exclude-created-before`**
- Do not lock pull requests created before a given timestamp,
- **`exclude-pr-created-before`**
- Do not lock pull requests created before a given date,
value must follow ISO 8601, ignored
when `exclude-pr-created-between` is set
- Optional, defaults to `''`
- **`exclude-pr-created-after`**
- Do not lock pull requests created after a given date,
value must follow ISO 8601, ignored
when `exclude-pr-created-between` is set
- Optional, defaults to `''`
- **`exclude-pr-created-between`**
- Do not lock pull requests created in a given time interval,
value must follow ISO 8601
- Optional, defaults to `''`
- **`exclude-pr-closed-before`**
- Do not lock pull requests closed before a given date,
value must follow ISO 8601, ignored
when `exclude-pr-closed-between` is set
- Optional, defaults to `''`
- **`exclude-pr-closed-after`**
- Do not lock pull requests closed after a given date,
value must follow ISO 8601, ignored
when `exclude-pr-closed-between` is set
- Optional, defaults to `''`
- **`exclude-pr-closed-between`**
- Do not lock pull requests closed in a given time interval,
value must follow ISO 8601
- Optional, defaults to `''`
- **`pr-exclude-labels`**
- Do not lock pull requests with these labels, value must
be a comma separated list of labels or `''`
- **`include-any-pr-labels`**
- Only lock pull requests with any of these labels, value must be
a comma separated list of labels or `''`, ignored
when `include-all-pr-labels` is set
- Optional, defaults to `''`
- **`include-all-pr-labels`**
- Only lock pull requests with all these labels, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`exclude-any-pr-labels`**
- Do not lock pull requests with any of these labels, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`pr-lock-labels`**
- **`add-pr-labels`**
- Labels to add before locking a pull request, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`pr-lock-comment`**
- **`remove-pr-labels`**
- Labels to remove before locking a pull request, value must be
a comma separated list of labels or `''`
- Optional, defaults to `''`
- **`pr-comment`**
- Comment to post before locking a pull request
- Optional, defaults to `''`
- **`pr-lock-reason`**
Expand All @@ -76,6 +150,9 @@ The action can be configured using [input parameters](https://docs.github.com/en
- Limit locking to only issues or pull requests, value must be
one of `issues`, `prs` or `''`
- Optional, defaults to `''`
- **`log-output`**
- Log output parameters, value must be either `true` or `false`
- Optional, defaults to `false`

### Outputs

Expand All @@ -92,7 +169,8 @@ The action can be configured using [input parameters](https://docs.github.com/en
## Examples

The following workflow will search once an hour for closed issues
and pull requests that can be locked.
and pull requests that have not had any activity
in the past year and can be locked.

<!-- prettier-ignore -->
```yaml
Expand All @@ -114,7 +192,7 @@ jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@v3
```
Edit the workflow after the initial backlog of issues and pull requests
Expand Down Expand Up @@ -153,36 +231,53 @@ jobs:
action:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@v3
with:
github-token: ${{ github.token }}
issue-lock-inactive-days: '365'
issue-exclude-created-before: ''
issue-exclude-labels: ''
issue-lock-labels: ''
issue-lock-comment: ''
issue-inactive-days: '365'
exclude-issue-created-before: ''
exclude-issue-created-after: ''
exclude-issue-created-between: ''
exclude-issue-closed-before: ''
exclude-issue-closed-after: ''
exclude-issue-closed-between: ''
include-any-issue-labels: ''
include-all-issue-labels: ''
exclude-any-issue-labels: ''
add-issue-labels: ''
remove-issue-labels: ''
issue-comment: ''
issue-lock-reason: 'resolved'
pr-lock-inactive-days: '365'
pr-exclude-created-before: ''
pr-exclude-labels: ''
pr-lock-labels: ''
pr-lock-comment: ''
pr-inactive-days: '365'
exclude-pr-created-before: ''
exclude-pr-created-after: ''
exclude-pr-created-between: ''
exclude-pr-closed-before: ''
exclude-pr-closed-after: ''
exclude-pr-closed-between: ''
include-any-pr-labels: ''
include-all-pr-labels: ''
exclude-any-pr-labels: ''
add-pr-labels: ''
remove-pr-labels: ''
pr-comment: ''
pr-lock-reason: 'resolved'
process-only: ''
log-output: false
```
### Excluding issues and pull requests
### Filtering issues and pull requests
This step will lock only issues, and exclude issues created before 2018,
or those with the `upstream` or `help-wanted` labels applied.

<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@v3
with:
issue-exclude-created-before: '2018-01-01T00:00:00Z'
issue-exclude-labels: 'upstream, help-wanted'
exclude-issue-created-before: '2018-01-01T00:00:00Z'
exclude-any-issue-labels: 'upstream, help-wanted'
process-only: 'issues'
```

Expand All @@ -192,12 +287,51 @@ with the `wip` label applied.
<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@v3
with:
pr-exclude-labels: 'wip'
exclude-any-pr-labels: 'wip'
process-only: 'prs'
```

This step will lock only issues, and exclude issues closed before 2018,
or those created in 2018 and 2019.

<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v3
with:
exclude-issue-created-between: '2018-01-01T00:00:00Z/2019-12-31T23:59:59.999Z'
exclude-issue-closed-before: '2018-01-01T00:00:00Z'
process-only: 'issues'
```

This step will lock issues that have the `incomplete` _or_ `invalid`
labels applied, and pull requests that have the `qa: done` _and_ `published`
labels applied.

<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v3
with:
include-any-issue-labels: 'incomplete, invalid'
include-all-pr-labels: 'qa: done, published'
```

This step will lock issues that have not had any activity in the past 180 days.

<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v3
with:
issue-inactive-days: '180'
process-only: 'issues'
```

### Commenting and labeling

This step will post a comment on issues and pull requests before locking them,
Expand All @@ -206,19 +340,32 @@ and apply the `outdated` label to issues.
<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@v3
with:
issue-lock-labels: 'outdated'
issue-lock-comment: >
add-issue-labels: 'outdated'
issue-comment: >
This issue has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
pr-lock-comment: >
pr-comment: >
This pull request has been automatically locked since there
has not been any recent activity after it was closed.
Please open a new issue for related bugs.
```

This step will apply the `qa: done` and `archived` labels,
and remove the `qa: primary` and `needs: user feedback` labels
before locking issues.

<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v3
with:
add-issue-labels: 'qa: done, archived'
remove-issue-labels: 'qa: primary, needs: user feedback'
```

### Using a personal access token

The action uses an installation access token by default to interact with GitHub.
Expand All @@ -234,7 +381,7 @@ using the `github-token` input parameter.
<!-- prettier-ignore -->
```yaml
steps:
- uses: dessant/lock-threads@v2
- uses: dessant/lock-threads@v3
with:
github-token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
```
Expand All @@ -248,9 +395,9 @@ applying or removing milestones, or pushing commits.

An easy way to check and see which issues or pull requests will initially
be locked is to add the `updated` search qualifier to either the issue
or pull request page filter for your repository:
or pull request search field for your repository:
`is:closed is:unlocked updated:<2018-12-20`.
Adjust the date to be 365 days ago (or whatever you set for `*-lock-inactive-days`)
Adjust the date to be 365 days ago (or whatever you set for `*-inactive-days`)
to see which issues or pull requests will be locked.

## Why are only some issues and pull requests processed?
Expand Down
Loading

0 comments on commit 26fd836

Please sign in to comment.