Skip to content

Commit 065e37e

Browse files
authored
Merge pull request #16 from matmar10/fix-log-success
fix: show success report
2 parents 375989b + 54a7ae3 commit 065e37e

File tree

2 files changed

+44
-42
lines changed

2 files changed

+44
-42
lines changed

dist/index.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,6 +1538,7 @@ async function run() {
15381538
try {
15391539
const token = core.getInput('token', { required: true });
15401540
const createComment = core.getBooleanInput('comment');
1541+
console.log('createComment', createComment);
15411542

15421543
// load rules from file, if there
15431544
const configPath = core.getInput('config_path', { required: true });
@@ -1645,7 +1646,11 @@ ${warningReportText}
16451646

16461647
if (countErrors) {
16471648
core.setFailed(`Action failed with ${countErrors} errors (and ${countWarnings} warnings)`);
1648-
const finalReport = `
1649+
}
1650+
1651+
if (createComment) {
1652+
if (countErrors || countWarnings) {
1653+
const finalReport = `
16491654
# 🚨🚔 Unconventional Commit 👮‍♀️🙅‍♂️
16501655

16511656
🤖 Beep boop! Looks like one or more of your commit messages wasn't quite right.
@@ -1670,23 +1675,15 @@ git commit --amend
16701675
\`\`\`
16711676

16721677
To edit & merge multiple commits, you can rebase with \`git rebase -i master\` (be sure your master is up to date).
1673-
1674-
`;
1675-
1676-
if (createComment) {
1677-
if (countErrors || countWarnings) {
1678-
await octokit.rest.issues.createComment({
1679-
owner,
1680-
repo: repo.name,
1681-
issue_number: num,
1682-
body: finalReport,
1683-
});
1684-
} else {
1685-
await octokit.rest.issues.createComment({
1686-
owner,
1687-
repo: repo.name,
1688-
issue_number: num,
1689-
body: `
1678+
`;
1679+
await octokit.rest.issues.createComment({
1680+
owner,
1681+
repo: repo.name,
1682+
issue_number: num,
1683+
body: finalReport,
1684+
});
1685+
} else {
1686+
const finalReport = `
16901687
# ✅🙏🏻 Conventional Commit 🥳 🎉
16911688

16921689
🤖 Beep boop! Congrats, it like all your commit messages conform to the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) spec! 👏👏👏
@@ -1699,9 +1696,13 @@ Your PR can be closed. Coffee is for closers, so here's a coffee for you: ☕️
16991696
- 👤 **${authors.length} author(s)**
17001697
- ❌ **${countErrors} lint error(s)**
17011698
- ⚠️ **${countWarnings} lint warning(s)**
1702-
`,
1703-
});
1704-
}
1699+
`;
1700+
await octokit.rest.issues.createComment({
1701+
owner,
1702+
repo: repo.name,
1703+
issue_number: num,
1704+
body: finalReport,
1705+
});
17051706
}
17061707
}
17071708
} catch (err) {

index.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ async function run() {
1919
try {
2020
const token = core.getInput('token', { required: true });
2121
const createComment = core.getBooleanInput('comment');
22+
console.log('createComment', createComment);
2223

2324
// load rules from file, if there
2425
const configPath = core.getInput('config_path', { required: true });
@@ -126,7 +127,11 @@ ${warningReportText}
126127

127128
if (countErrors) {
128129
core.setFailed(`Action failed with ${countErrors} errors (and ${countWarnings} warnings)`);
129-
const finalReport = `
130+
}
131+
132+
if (createComment) {
133+
if (countErrors || countWarnings) {
134+
const finalReport = `
130135
# 🚨🚔 Unconventional Commit 👮‍♀️🙅‍♂️
131136
132137
🤖 Beep boop! Looks like one or more of your commit messages wasn't quite right.
@@ -151,23 +156,15 @@ git commit --amend
151156
\`\`\`
152157
153158
To edit & merge multiple commits, you can rebase with \`git rebase -i master\` (be sure your master is up to date).
154-
155-
`;
156-
157-
if (createComment) {
158-
if (countErrors || countWarnings) {
159-
await octokit.rest.issues.createComment({
160-
owner,
161-
repo: repo.name,
162-
issue_number: num,
163-
body: finalReport,
164-
});
165-
} else {
166-
await octokit.rest.issues.createComment({
167-
owner,
168-
repo: repo.name,
169-
issue_number: num,
170-
body: `
159+
`;
160+
await octokit.rest.issues.createComment({
161+
owner,
162+
repo: repo.name,
163+
issue_number: num,
164+
body: finalReport,
165+
});
166+
} else {
167+
const finalReport = `
171168
# ✅🙏🏻 Conventional Commit 🥳 🎉
172169
173170
🤖 Beep boop! Congrats, it like all your commit messages conform to the [Conventional Commit](https://www.conventionalcommits.org/en/v1.0.0/) spec! 👏👏👏
@@ -180,9 +177,13 @@ Your PR can be closed. Coffee is for closers, so here's a coffee for you: ☕️
180177
- 👤 **${authors.length} author(s)**
181178
- ❌ **${countErrors} lint error(s)**
182179
- ⚠️ **${countWarnings} lint warning(s)**
183-
`,
184-
});
185-
}
180+
`;
181+
await octokit.rest.issues.createComment({
182+
owner,
183+
repo: repo.name,
184+
issue_number: num,
185+
body: finalReport,
186+
});
186187
}
187188
}
188189
} catch (err) {

0 commit comments

Comments
 (0)