Helper to filter GitHub Action.
npm install @technote-space/filter-github-action




Read this in other languages: English, 日本語.
GitHub Actions を Context などでフィルタリングするためのヘルパー
Details
- 使用方法
- 上の例の結果
- Ignore check
- Author
npm i @technote-space/filter-github-actiontypescript
import { Context } from '@actions/github/lib/context';
import { context } from '@actions/github';
import { isTargetEvent, isTargetLabels } from '@technote-space/filter-github-action';console.log( isTargetEvent( {
'release': [
// or
'published',
'rerequested',
],
'push': [
// use context
(context: Context): boolean => /^refs\/tags\//.test(context.ref),
'rerequested',
],
'pull_request': [
// or
[
// and
(context: Context): boolean => /^refs\/tags\//.test(context.ref),
'rerequested',
],
],
// wildcard
'project_card': '*',
}, context ) );
const includes = ['label1', 'label2'];
const excludes = ['label3', 'label4'];
console.log( isTargetLabels( includes, excludes, context ) );
`$3
#### isTargetEvent
|eventName|action|ref|result|
|:---:|:---:|:---:|:---:|
|release|published|*|true|
|release|rerequested|*|true|
|release|created|*|false|
|push|*|refs/tags/v1.2.3|true|
|push|*|refs/heads/v1.2.3|false|
|push|rerequested|*|true|
|pull_request|rerequested|refs/tags/v1.2.3|true|
|pull_request|created|refs/tags/v1.2.3|false|
|pull_request|rerequested|refs/heads/v1.2.3|false|
|project_card|||true|
|label|||false|#### isTargetLabels
|eventName|context labels|includes|excludes|result|
|:---:|:---:|:---:|:---:|:---:|
|issues|---|---|---|true|
|pull_request|---|---|---|true|
|push|---|---|---|true|
|issues|label1|---|---|true|
|issues|---|label1|---|false|
|issues|label1|label1|---|true|
|issues|label1, label2|label1|---|true|
|issues|label1|label1, label2|---|true|
|issues|---|---|label1|true|
|issues|label1|---|label1|false|
|issues|label1, label2|label1|label2|false|
|issues|label1, label2|label1|label3|true|
$3
`
with:
IGNORE_CONTEXT_CHECK: true
``