4 Commits

Author SHA1 Message Date
xrkffgg
78a8afb859 feat: add filterLabel (#19)
* feat: add filterLabel

* add changelog
2021-03-17 15:10:57 +08:00
xrkffgg
dd11fb5133 Update extract-issues.yml 2021-03-17 14:57:49 +08:00
xrkffgg
ae5b70b9f0 Update README.md 2021-03-12 10:22:02 +08:00
xrkffgg
ec59498db2 Update CHANGELOG.md 2021-03-12 10:17:49 +08:00
6 changed files with 71 additions and 8 deletions

View File

@@ -8,10 +8,11 @@ jobs:
welcome: welcome:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions-cool/pr-extract-issues@main - uses: actions-cool/pr-extract-issues@t
with: with:
way: 'commit' way: 'commit'
issues-labels: 'l1, l2' issues-labels: 'l1, l2'
filter-label: 'bug'
issues-comment: | issues-comment: |
HI。这个 issue: ${number} 已经被修复了。 HI。这个 issue: ${number} 已经被修复了。
issues-close: true issues-close: true

View File

@@ -1,7 +1,13 @@
# Changelog # 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 ## v1.0.0
`2021.xx.xx` `2021.03.12`
- 🎉 Init. - 🎉 Init.

View File

@@ -4,6 +4,8 @@
[![](https://img.shields.io/badge/marketplace-pr--extract--issues-blueviolet?style=flat-square)](https://github.com/marketplace/actions/pr-extract-issues) [![](https://img.shields.io/badge/marketplace-pr--extract--issues-blueviolet?style=flat-square)](https://github.com/marketplace/actions/pr-extract-issues)
[![](https://img.shields.io/github/v/release/actions-cool/pr-extract-issues?style=flat-square&color=orange)](https://github.com/actions-cool/pr-extract-issues/releases) [![](https://img.shields.io/github/v/release/actions-cool/pr-extract-issues?style=flat-square&color=orange)](https://github.com/actions-cool/pr-extract-issues/releases)
A GitHub Action help you extract issues from pr commit or title or body.
## 🚀 How to use? ## 🚀 How to use?
### Preview ### Preview
@@ -23,7 +25,7 @@ jobs:
extract: extract:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions-cool/pr-extract-issues@v1.0.0 - uses: actions-cool/pr-extract-issues@v1.1.0
with: with:
way: 'commit' way: 'commit'
issues-labels: 'l1, l2' issues-labels: 'l1, l2'
@@ -38,6 +40,7 @@ jobs:
| -- | -- | -- | -- | | -- | -- | -- | -- |
| token | GitHub token | string | ✖ | | token | GitHub token | string | ✖ |
| way | The way to query issues. Options: `title` `body` `commit` | 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-labels | Extra labels on issues | string | ✖ |
| issues-comment | Extra comment on issues | string | ✖ | | issues-comment | Extra comment on issues | string | ✖ |
| issues-close | Extra close issues | string | ✖ | | issues-close | Extra close issues | string | ✖ |
@@ -52,6 +55,7 @@ jobs:
- Like: https://github.com/actions-cool/pr-extract-issues/pull/4 - Like: https://github.com/actions-cool/pr-extract-issues/pull/4
- Branch whole line display with # start - Branch whole line display with # start
- `commit`: Like `title` - `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-labels`: Support multiple, need to be separated by comma
- `issues-comment`: `${number}` will be replaced with the current issue number - `issues-comment`: `${number}` will be replaced with the current issue number
- `issues-close`: Whether close issue - `issues-close`: Whether close issue

View File

@@ -10,12 +10,14 @@ branding:
inputs: inputs:
token: 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 }} default: ${{ github.token }}
required: true required: true
way: way:
description: The way to query issues. description: The way to query issues
required: true required: true
filter-label:
description: Further filter issues through label
issues-labels: issues-labels:
description: Extra operations on issues description: Extra operations on issues
issues-comment: issues-comment:
@@ -25,7 +27,7 @@ inputs:
outputs: outputs:
issues: issues:
description: Get issues numbers. description: Get issues numbers
runs: runs:
using: 'node12' 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!'); 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.info(`[Action: Query Issues][${issues}]`);
core.setOutput('issues', issues); core.setOutput('issues', issues);