diff --git a/.github/scripts/label_pr_based_on_title.js b/.github/scripts/label_pr_based_on_title.js index 463264155bf..4ae3c1ff321 100644 --- a/.github/scripts/label_pr_based_on_title.js +++ b/.github/scripts/label_pr_based_on_title.js @@ -1,12 +1,12 @@ const { PR_NUMBER, PR_TITLE, AREAS } = require("./constants") module.exports = async ({github, context, core}) => { - const FEAT_REGEX = /feat(\((.+)\))?(\:.+)/ - const BUG_REGEX = /(fix|bug)(\((.+)\))?(\:.+)/ - const DOCS_REGEX = /(docs|doc)(\((.+)\))?(\:.+)/ - const CHORE_REGEX = /(chore)(\((.+)\))?(\:.+)/ - const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(\:.+)/ - const REFACTOR_REGEX = /(refactor)(\((.+)\))?(\:.+)/ + const FEAT_REGEX = /feat(\((.+)\))?(:.+)/ + const BUG_REGEX = /(fix|bug)(\((.+)\))?(:.+)/ + const DOCS_REGEX = /(docs|doc)(\((.+)\))?(:.+)/ + const CHORE_REGEX = /(chore)(\((.+)\))?(:.+)/ + const DEPRECATED_REGEX = /(deprecated)(\((.+)\))?(:.+)/ + const REFACTOR_REGEX = /(refactor)(\((.+)\))?(:.+)/ const labels = { "feature": FEAT_REGEX, @@ -22,8 +22,8 @@ module.exports = async ({github, context, core}) => { try { for (const label in labels) { const matcher = new RegExp(labels[label]) - const isMatch = matcher.exec(PR_TITLE) - if (isMatch != null) { + const matches = matcher.exec(PR_TITLE) + if (matches != null) { core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`) await github.rest.issues.addLabels({ @@ -54,7 +54,7 @@ module.exports = async ({github, context, core}) => { } } finally { if (miss == Object.keys(labels).length) { - return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) + core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) } } } diff --git a/.github/scripts/label_related_issue.js b/.github/scripts/label_related_issue.js index 93ac1583a1c..e01868d36dc 100644 --- a/.github/scripts/label_related_issue.js +++ b/.github/scripts/label_related_issue.js @@ -19,8 +19,9 @@ module.exports = async ({github, context, core}) => { const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?\d+)/; + const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY); + try { - const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY); if (!isMatch) { core.setFailed(`Unable to find related issue for PR number ${PR_NUMBER}.\n\n Body details: ${PR_BODY}`); return await github.rest.issues.createComment({ @@ -30,11 +31,16 @@ module.exports = async ({github, context, core}) => { issue_number: PR_NUMBER, }); } + } catch (error) { + core.setFailed(`Unable to create comment on PR number ${PR_NUMBER}.\n\n Error details: ${error}`); + throw new Error(error); + } - const { groups: {issue} } = isMatch + const { groups: {issue} } = isMatch + try { core.info(`Auto-labeling related issue ${issue} for release`) - return await github.rest.issues.addLabels({ + await github.rest.issues.addLabels({ issue_number: issue, owner: context.repo.owner, repo: context.repo.repo, diff --git a/.github/scripts/save_pr_details.js b/.github/scripts/save_pr_details.js index bc3de6734c9..83bd3bf70d4 100644 --- a/.github/scripts/save_pr_details.js +++ b/.github/scripts/save_pr_details.js @@ -1,4 +1,4 @@ -module.exports = async ({github, context, core}) => { +module.exports = async ({context, core}) => { const fs = require('fs'); const filename = "pr.txt"; @@ -10,4 +10,4 @@ module.exports = async ({github, context, core}) => { core.setFailed("Failed to save PR details"); console.error(err); } -} \ No newline at end of file +}