Skip to content

Commit a084826

Browse files
committed
Rename yaml_file input to yaml-file
Rename skip_delete input to skip-delete Rename dry_run input to dry-run
1 parent 1ff1894 commit a084826

File tree

6 files changed

+70
-45
lines changed

6 files changed

+70
-45
lines changed

.github/workflows/ci.yml

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@ jobs:
2424
uses: ./
2525
with:
2626
github-token: ${{ secrets.GITHUB_TOKEN }}
27-
yaml_file: .res/labels.update.yml
28-
skip_delete: true
29-
dry_run: true
27+
yaml-file: .res/labels.update.yml
28+
skip-delete: true
29+
dry-run: true
3030
-
3131
name: Labeler (exclude part 1)
3232
uses: ./
3333
with:
3434
github-token: ${{ secrets.GITHUB_TOKEN }}
35-
yaml_file: .res/labels.exclude1.yml
36-
dry_run: true
35+
yaml-file: .res/labels.exclude1.yml
36+
dry-run: true
3737
exclude: |
3838
* d*
3939
*enhancement
@@ -43,7 +43,7 @@ jobs:
4343
uses: ./
4444
with:
4545
github-token: ${{ secrets.GITHUB_TOKEN }}
46-
yaml_file: .res/labels.exclude2.yml
47-
dry_run: true
46+
yaml-file: .res/labels.exclude2.yml
47+
dry-run: true
4848
exclude: |
4949
*fix

README.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ jobs:
7171
uses: crazy-max/ghaction-github-labeler@v2
7272
with:
7373
github-token: ${{ secrets.GITHUB_TOKEN }}
74-
yaml_file: .github/labels.yml
75-
skip_delete: false
76-
dry_run: false
74+
yaml-file: .github/labels.yml
75+
skip-delete: false
76+
dry-run: false
7777
exclude: |
7878
help*
7979
*issue
@@ -97,13 +97,13 @@ With this workflow, the YAML configuration above on a [fresh repository](.res/sa
9797

9898
Following inputs can be used as `step.with` keys
9999

100-
| Name | Type | Description |
101-
|-----------------|----------|------------------------------------------------------------------------------------|
102-
| `github-token` | String | [GitHub Token](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) as provided by `secrets` |
103-
| `yaml_file` | String | Path to YAML file containing labels definitions (default `.github/labels.yml`) |
104-
| `skip_delete` | Bool | If enabled, labels will not be deleted if not found in YAML file (default `false`) |
105-
| `dry_run` | Bool | If enabled, changes will not be applied (default `false`) |
106-
| `exclude` | String | Newline-delimited list of labels pattern(s)/matcher to exclude. |
100+
| Name | Type | Default | Description |
101+
|------------------|---------|------------------------|------------------------------------|
102+
| `github-token` | String | `${{ github.token }}` | [GitHub Token](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token) as provided by `secrets` |
103+
| `yaml-file` | String | `.github/labels.yml` | Path to YAML file containing labels definitions |
104+
| `skip-delete` | Bool | `false` | If enabled, labels will not be deleted if not found in YAML file |
105+
| `dry-run` | Bool | `false` | If enabled, changes will not be applied |
106+
| `exclude` | List | | Comma or newline delimited list of labels pattern(s)/matcher to exclude |
107107

108108
## Keep up-to-date with GitHub Dependabot
109109

action.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,19 @@ branding:
77
icon: 'tag'
88

99
inputs:
10-
yaml_file:
10+
github-token:
11+
description: 'GitHub Token as provided by secrets'
12+
default: ${{ github.token }}
13+
required: true
14+
yaml-file:
1115
description: 'Path to YAML file containing labels definitions'
1216
default: '.github/labels.yml'
1317
required: false
14-
skip_delete:
18+
skip-delete:
1519
description: 'If enabled, labels will not be deleted if not found in YAML file'
1620
default: 'false'
1721
required: false
18-
dry_run:
22+
dry-run:
1923
description: 'If enabled, changes will not be applied'
2024
default: 'false'
2125
required: false

dist/index.js

+22-11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/context.ts

+20-3
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,30 @@ export interface Inputs {
77
yamlFile: fs.PathLike;
88
skipDelete: boolean;
99
dryRun: boolean;
10+
exclude: string[];
1011
}
1112

1213
export async function getInputs(): Promise<Inputs> {
1314
return {
1415
githubToken: core.getInput('github-token'),
15-
yamlFile: path.join(core.getInput('yaml_file') || '.github/labels.yml'),
16-
skipDelete: /true/i.test(core.getInput('skip_delete')),
17-
dryRun: /true/i.test(core.getInput('dry_run'))
16+
yamlFile: path.join(core.getInput('yaml-file') || '.github/labels.yml'),
17+
skipDelete: /true/i.test(core.getInput('skip-delete')),
18+
dryRun: /true/i.test(core.getInput('dry-run')),
19+
exclude: await getInputList('exclude')
1820
};
1921
}
22+
23+
export async function getInputList(name: string): Promise<string[]> {
24+
const items = core.getInput(name);
25+
if (items == '') {
26+
return [];
27+
}
28+
return items.split(/\r?\n/).reduce<string[]>(
29+
(acc, line) =>
30+
acc
31+
.concat(line.split(','))
32+
.filter(pat => pat)
33+
.map(pat => pat.trim()),
34+
[]
35+
);
36+
}

src/main.ts

+4-11
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as core from '@actions/core';
55
import * as github from '@actions/github';
66
import {getInputs, Inputs} from './context';
77

8+
let inputs: Inputs;
89
let octokit;
910
let liveLabels: Array<Label>;
1011
let fileLabels: Array<Label>;
@@ -31,7 +32,7 @@ enum LabelStatus {
3132

3233
async function run() {
3334
try {
34-
let inputs: Inputs = await getInputs();
35+
inputs = await getInputs();
3536
octokit = github.getOctokit(inputs.githubToken);
3637

3738
if (!fs.existsSync(inputs.yamlFile)) {
@@ -200,20 +201,12 @@ async function displayLiveLabels() {
200201
}
201202

202203
async function getExclusions(): Promise<string[]> {
203-
const patterns = core.getInput('exclude');
204-
if (patterns == '') {
204+
if (inputs.exclude.length == 0) {
205205
return [];
206206
}
207207
return matcher(
208208
liveLabels.map(label => label.name),
209-
patterns.split(/\r?\n/).reduce<string[]>(
210-
(acc, line) =>
211-
acc
212-
.concat(line.split(','))
213-
.filter(pat => pat)
214-
.map(pat => pat.trim()),
215-
[]
216-
)
209+
inputs.exclude
217210
);
218211
}
219212

0 commit comments

Comments
 (0)