feat: add filterLabel (#19)

* feat: add filterLabel

* add changelog
This commit is contained in:
xrkffgg
2021-03-17 15:10:57 +08:00
committed by GitHub
parent dd11fb5133
commit 78a8afb859
5 changed files with 66 additions and 6 deletions

View File

@@ -1,5 +1,11 @@
# Changelog
## v1.1.0
`2021.03.17`
- feat: add `filter-label`. [#19](https://github.com/actions-cool/pr-extract-issues/pull/19)
## v1.0.0
`2021.03.12`

View File

@@ -25,7 +25,7 @@ jobs:
extract:
runs-on: ubuntu-latest
steps:
- uses: actions-cool/pr-extract-issues@v1.0.0
- uses: actions-cool/pr-extract-issues@v1.1.0
with:
way: 'commit'
issues-labels: 'l1, l2'
@@ -40,6 +40,7 @@ jobs:
| -- | -- | -- | -- |
| token | GitHub token | string | ✖ |
| way | The way to query issues. Options: `title` `body` `commit` | string | ✔ |
| filter-label | Further filter issues through label | string | ✖ |
| issues-labels | Extra labels on issues | string | ✖ |
| issues-comment | Extra comment on issues | string | ✖ |
| issues-close | Extra close issues | string | ✖ |
@@ -54,6 +55,7 @@ jobs:
- Like: https://github.com/actions-cool/pr-extract-issues/pull/4
- Branch whole line display with # start
- `commit`: Like `title`
- `filter-label`: Note that github default hooks. That is, `fix` `close` `resolve` directly followed by issue number will be closed after success merge
- `issues-labels`: Support multiple, need to be separated by comma
- `issues-comment`: `${number}` will be replaced with the current issue number
- `issues-close`: Whether close issue

View File

@@ -10,12 +10,14 @@ branding:
inputs:
token:
description: Secret GitHub API token to use for making API requests.
description: Secret GitHub API token to use for making API requests
default: ${{ github.token }}
required: true
way:
description: The way to query issues.
description: The way to query issues
required: true
filter-label:
description: Further filter issues through label
issues-labels:
description: Extra operations on issues
issues-comment:
@@ -25,7 +27,7 @@ inputs:
outputs:
issues:
description: Get issues numbers.
description: Get issues numbers
runs:
using: 'node12'

35
dist/index.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -55,6 +55,25 @@ async function run() {
core.setFailed('Wrong way!');
}
const filterLabel = core.getInput('filter-label');
if (filterLabel) {
let arr = [];
for await (let no of issues) {
const {
data: { labels },
} = await octokit.issues.get({
owner,
repo,
issue_number: no,
});
let o = labels.find(k => k.name == filterLabel);
if (o) {
arr.push(no);
}
}
issues = [...arr];
}
core.info(`[Action: Query Issues][${issues}]`);
core.setOutput('issues', issues);