Skip to content

Commit

Permalink
feat: Change default config file name
Browse files Browse the repository at this point in the history
  • Loading branch information
peaceiris committed Mar 8, 2020
1 parent 97b68d8 commit 1dc6713
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .github/commenter.yml → .github/label-commenter-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ labels:
issue:
body: This issue or pull request already exists.
action: close
- name: good first issue
labeled:
issue:
body: This issue is easy for contributing. Everyone can work on this.
2 changes: 1 addition & 1 deletion .github/workflows/commenter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ jobs:
uses: peaceiris/actions-label-commenter@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# config_file: .github/commenter.yml
# config_file: .github/label-commenter-config.yml
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
uses: peaceiris/actions-label-commenter@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
# config_file: .github/commenter.yml
# config_file: .github/label-commenter-config.yml
```

### Action Setting
Expand Down Expand Up @@ -91,6 +91,10 @@ labels:
issue:
body: This issue or pull request already exists.
action: close
- name: good first issue
labeled:
issue:
body: This issue is easy for contributing. Everyone can work on this.
```
Expand Down
9 changes: 6 additions & 3 deletions __tests__/get-inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,19 @@ describe('getInputs()', () => {
const inps: Inputs = getInputs();

expect(inps.GithubToken).toMatch('secret_token');
expect(inps.ConfigFilePath).toMatch('.github/commenter.yml');
expect(inps.ConfigFilePath).toMatch('.github/label-commenter-config.yml');
});

test('get spec inputs', () => {
process.env['INPUT_GITHUB_TOKEN'] = 'secret_token';
process.env['INPUT_CONFIG_FILE'] = '.github/config/commenter.yml';
process.env['INPUT_CONFIG_FILE'] =
'.github/config/label-commenter-config.yml';

const inps: Inputs = getInputs();

expect(inps.GithubToken).toMatch('secret_token');
expect(inps.ConfigFilePath).toMatch('.github/config/commenter.yml');
expect(inps.ConfigFilePath).toMatch(
'.github/config/label-commenter-config.yml'
);
});
});
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ inputs:
required: true
config_file:
description: 'Path to action setting file'
default: '.github/commenter.yml'
default: '.github/label-commenter-config.yml'
required: false
runs:
using: 'node12'
Expand Down
10 changes: 8 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,14 @@ export async function run(): Promise<void> {
});

if (!isExistLabel) {
core.info(`[INFO] no configuration for ${labelName}`);
core.info(`[INFO] no configuration for labels.${labelName}`);
return;
}

if (config.labels[labelIndex][`${labelEvent}`] === void 0) {
core.info(`[INFO] no configuration for ${labelName} ${labelEvent}`);
core.info(
`[INFO] no configuration for labels.${labelName}.${labelEvent}`
);
return;
}

Expand Down Expand Up @@ -131,6 +133,10 @@ export async function run(): Promise<void> {
await closeIssue(githubClient, issueNumber);
} else if (finalAction === 'open') {
await openIssue(githubClient, issueNumber);
} else {
core.info(
`[INFO] no configuration for labels.${labelName}.${labelEvent}.${eventType}.action`
);
}

return;
Expand Down

0 comments on commit 1dc6713

Please sign in to comment.