https://github.com/technote-space/filter-github-action
Helper to filter GitHub Actions
https://github.com/technote-space/filter-github-action
github-actions
Last synced: 9 months ago
JSON representation
Helper to filter GitHub Actions
- Host: GitHub
- URL: https://github.com/technote-space/filter-github-action
- Owner: technote-space
- License: mit
- Created: 2019-09-19T18:27:12.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-12-26T09:02:00.000Z (almost 2 years ago)
- Last Synced: 2025-03-26T23:39:00.264Z (9 months ago)
- Topics: github-actions
- Language: TypeScript
- Homepage:
- Size: 3 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.ja.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Filter GitHub Action
[](https://badge.fury.io/js/%40technote-space%2Ffilter-github-action)
[](https://github.com/technote-space/filter-github-action/actions)
[](https://codecov.io/gh/technote-space/filter-github-action)
[](https://www.codefactor.io/repository/github/technote-space/filter-github-action)
[](https://github.com/technote-space/filter-github-action/blob/master/LICENSE)
*Read this in other languages: [English](README.md), [日本語](README.ja.md).*
GitHub Actions を Context などでフィルタリングするためのヘルパー
## Table of Contents
Details
- [使用方法](#%E4%BD%BF%E7%94%A8%E6%96%B9%E6%B3%95)
- [上の例の結果](#%E4%B8%8A%E3%81%AE%E4%BE%8B%E3%81%AE%E7%B5%90%E6%9E%9C)
- [Ignore check](#ignore-check)
- [Author](#author)
## 使用方法
1. インストール
`npm i @technote-space/filter-github-action`
1.
```typescript
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 ) );
```
### 上の例の結果
#### 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|
### Ignore check
```
with:
IGNORE_CONTEXT_CHECK: true
```
## Author
[GitHub (Technote)](https://github.com/technote-space)
[Blog](https://technote.space)