Skip to content

Commit

Permalink
fix(ci): address pr title semantic not found logic
Browse files Browse the repository at this point in the history
  • Loading branch information
heitorlessa committed Jul 13, 2022
1 parent 8612920 commit 742ccf5
Showing 1 changed file with 21 additions and 15 deletions.
36 changes: 21 additions & 15 deletions .github/scripts/label_pr_based_on_title.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,28 @@ module.exports = async ({github, context, core}) => {
}

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

await github.rest.issues.addLabels({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label]
})

break
return await github.rest.issues.addLabels({
issue_number: PR_NUMBER,
owner: context.repo.owner,
repo: context.repo.repo,
labels: [label]
})
} else {
core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`)
miss += 1
}
}
} finally {
if (miss == Object.keys(labels).length) {
return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`)
}
}

return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`)
}

0 comments on commit 742ccf5

Please sign in to comment.