Skip to content

Commit b582992

Browse files
committed
fix(ci): address pr title semantic not found logic
1 parent 558d2e7 commit b582992

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

.github/scripts/label_pr_based_on_title.js

+21-15
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,28 @@ module.exports = async ({github, context, core}) => {
1818
}
1919

2020
// Maintenance: We should keep track of modified PRs in case their titles change
21-
for (const label in labels) {
22-
const matcher = new RegExp(labels[label])
23-
const isMatch = matcher.exec(PR_TITLE)
24-
if (isMatch != null) {
25-
core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`)
21+
let miss = 0;
22+
try {
23+
for (const label in labels) {
24+
const matcher = new RegExp(labels[label])
25+
const isMatch = matcher.exec(PR_TITLE)
26+
if (isMatch != null) {
27+
core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`)
2628

27-
await github.rest.issues.addLabels({
28-
issue_number: PR_NUMBER,
29-
owner: context.repo.owner,
30-
repo: context.repo.repo,
31-
labels: [label]
32-
})
33-
34-
break
29+
return await github.rest.issues.addLabels({
30+
issue_number: PR_NUMBER,
31+
owner: context.repo.owner,
32+
repo: context.repo.repo,
33+
labels: [label]
34+
})
35+
} else {
36+
core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`)
37+
miss += 1
38+
}
39+
}
40+
} finally {
41+
if (miss == Object.keys(labels).length) {
42+
return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`)
3543
}
3644
}
37-
38-
return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`)
3945
}

0 commit comments

Comments
 (0)