Skip to content

Commit e32fd7c

Browse files
authored
chore: standardize string quotes in action.yml and commit-message-validator.js (#1)
1 parent 3c3394f commit e32fd7c

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,13 @@ You can customize the regex pattern used for validation:
5757
## Default Conventional Commits Format
5858

5959
The default pattern validates the following format:
60+
6061
```
6162
<type>[optional scope]: <description>
6263
```
6364

6465
Where `type` is one of:
66+
6567
- feat: A new feature
6668
- fix: A bug fix
6769
- docs: Documentation changes
@@ -76,4 +78,5 @@ Where `type` is one of:
7678

7779
## License
7880

79-
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
81+
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
82+

action.yml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
name: 'Conventional Commit Validator'
2-
description: 'Validates that commit messages follow the Conventional Commits format'
1+
name: "Conventional Commit Validator"
2+
description: "Validates that commit messages follow the Conventional Commits format"
33
inputs:
44
github-token:
5-
description: 'GitHub token for API access'
5+
description: "GitHub token for API access"
66
required: true
77
default: ${{ github.token }}
88
pattern:
9-
description: 'Regex pattern for commit message validation'
9+
description: "Regex pattern for commit message validation"
1010
required: false
1111
default: '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\(\w+\))?: .+$'
1212
runs:
13-
using: 'node20'
14-
main: 'dist/index.js'
13+
using: "node20"
14+
main: "dist/index.js"
1515
branding:
16-
icon: 'check-circle'
17-
color: 'green'
16+
icon: "check-circle"
17+
color: "green"
18+

commit-message-validator.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ async function run() {
77
const token = core.getInput('github-token', { required: true });
88
const pattern = core.getInput('pattern') || '^(feat|fix|docs|style|refactor|perf|test|build|ci|chore|revert)(\\(\\w+\\))?: .+$';
99
const regexPattern = new RegExp(pattern);
10-
10+
1111
// Create octokit client
1212
const octokit = github.getOctokit(token);
1313
const context = github.context;
14-
14+
1515
// Get current PR
1616
const pullRequest = context.payload.pull_request;
1717
if (!pullRequest) {
1818
core.info('No pull request found. Skipping commit message validation.');
1919
return;
2020
}
21-
21+
2222
// Get commits in PR
2323
const { data: commits } = await octokit.rest.pulls.listCommits({
2424
owner: context.repo.owner,
2525
repo: context.repo.repo,
2626
pull_number: pullRequest.number,
2727
});
28-
28+
2929
let hasError = false;
3030
let errorMessages = [];
31-
31+
3232
// Validate each commit message
3333
commits.forEach((commit) => {
3434
const commitMessage = commit.commit.message.split('\n')[0].trim();
3535
const sha = commit.sha.substring(0, 7);
36-
36+
3737
if (!regexPattern.test(commitMessage)) {
3838
const errorMsg = `❌ Commit ${sha} has an invalid message format: "${commitMessage}"`;
3939
core.error(errorMsg);
@@ -43,7 +43,7 @@ async function run() {
4343
core.info(`✅ Commit ${sha} has a valid message: "${commitMessage}"`);
4444
}
4545
});
46-
46+
4747
// Fail the workflow if errors are found
4848
if (hasError) {
4949
core.setFailed(`One or more commits have invalid message format.\n${errorMessages.join('\n')}\n\nPlease follow the Conventional Commits format: <type>[optional scope]: <description>\nExample: feat(auth): add login functionality\n\nFor more information, visit: https://www.conventionalcommits.org/`);
@@ -55,4 +55,4 @@ async function run() {
5555
}
5656
}
5757

58-
run();
58+
run();

0 commit comments

Comments
 (0)