diff --git a/.github/scripts/constants.js b/.github/scripts/constants.js index 2eee0592c2d..2c1d6f9ab76 100644 --- a/.github/scripts/constants.js +++ b/.github/scripts/constants.js @@ -32,4 +32,23 @@ module.exports = Object.freeze({ /** @type {string[]} */ "IGNORE_AUTHORS": ["dependabot[bot]", "markdownify[bot]"], + + /** @type {string[]} */ + "AREAS": [ + "tracer", + "metrics", + "utilities", + "logger", + "event_handlers", + "middleware_factory", + "idempotency", + "event_sources", + "feature_flags", + "parameters", + "batch", + "parser", + "validator", + "jmespath_util", + "lambda-layers", + ], }); diff --git a/.github/scripts/label_pr_based_on_title.js b/.github/scripts/label_pr_based_on_title.js index dcbc562c596..463264155bf 100644 --- a/.github/scripts/label_pr_based_on_title.js +++ b/.github/scripts/label_pr_based_on_title.js @@ -1,4 +1,4 @@ -const { PR_NUMBER, PR_TITLE } = require("./constants") +const { PR_NUMBER, PR_TITLE, AREAS } = require("./constants") module.exports = async ({github, context, core}) => { const FEAT_REGEX = /feat(\((.+)\))?(\:.+)/ @@ -26,12 +26,27 @@ module.exports = async ({github, context, core}) => { if (isMatch != null) { core.info(`Auto-labeling PR ${PR_NUMBER} with ${label}`) - return await github.rest.issues.addLabels({ - issue_number: PR_NUMBER, - owner: context.repo.owner, - repo: context.repo.repo, - labels: [label] + await github.rest.issues.addLabels({ + issue_number: PR_NUMBER, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [label] }) + + const area = matches[2]; // second capture group contains the area + if (AREAS.indexOf(area) > -1) { + core.info(`Auto-labeling PR ${PR_NUMBER} with area ${area}`); + await github.rest.issues.addLabels({ + issue_number: PR_NUMBER, + owner: context.repo.owner, + repo: context.repo.repo, + labels: [`area/${area}`], + }); + } else { + core.debug(`'${PR_TITLE}' didn't match any known area.`); + } + + return; } else { core.debug(`'${PR_TITLE}' didn't match '${label}' semantic.`) miss += 1 @@ -42,4 +57,4 @@ module.exports = async ({github, context, core}) => { return core.notice(`PR ${PR_NUMBER} title '${PR_TITLE}' doesn't follow semantic titles; skipping...`) } } -} \ No newline at end of file +}