Skip to content

Commit 7826861

Browse files
author
Ran Isenberg
committed
feature: Kafka Parser support
1 parent dc88e7e commit 7826861

File tree

2 files changed

+1369
-764
lines changed

2 files changed

+1369
-764
lines changed
+39-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,53 @@
1-
module.exports = async ({github, context, core}) => {
2-
const prBody = context.payload.body;
3-
const prNumber = context.payload.number;
4-
const releaseLabel = process.env.RELEASE_LABEL;
5-
const maintainersTeam = process.env.MAINTAINERS_TEAM
1+
const {
2+
PR_AUTHOR,
3+
PR_BODY,
4+
PR_NUMBER,
5+
IGNORE_AUTHORS,
6+
LABEL_PENDING_RELEASE,
7+
HANDLE_MAINTAINERS_TEAM,
8+
PR_IS_MERGED,
9+
} = require("./constants")
610

7-
const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?<issue>\d+)/;
11+
module.exports = async ({ github, context, core }) => {
12+
if (IGNORE_AUTHORS.includes(PR_AUTHOR)) {
13+
return core.notice("Author in IGNORE_AUTHORS list; skipping...")
14+
}
815

9-
const isMatch = RELATED_ISSUE_REGEX.exec(prBody);
16+
if (PR_IS_MERGED == "false") {
17+
return core.notice("Only merged PRs to avoid spam; skipping")
18+
}
19+
20+
const RELATED_ISSUE_REGEX = /Issue number:[^\d\r\n]+(?<issue>\d+)/;
21+
22+
const isMatch = RELATED_ISSUE_REGEX.exec(PR_BODY);
23+
24+
try {
1025
if (!isMatch) {
11-
core.setFailed(`Unable to find related issue for PR number ${prNumber}.\n\n Body details: ${prBody}`);
26+
core.setFailed(`Unable to find related issue for PR number ${PR_NUMBER}.\n\n Body details: ${PR_BODY}`);
1227
return await github.rest.issues.createComment({
1328
owner: context.repo.owner,
1429
repo: context.repo.repo,
15-
body: `${maintainersTeam} No related issues found. Please ensure '${releaseLabel}' label is applied before releasing.`,
16-
issue_number: prNumber,
30+
body: `${HANDLE_MAINTAINERS_TEAM} No related issues found. Please ensure '${LABEL_PENDING_RELEASE}' label is applied before releasing.`,
31+
issue_number: PR_NUMBER,
1732
});
1833
}
34+
} catch (error) {
35+
core.setFailed(`Unable to create comment on PR number ${PR_NUMBER}.\n\n Error details: ${error}`);
36+
throw new Error(error);
37+
}
1938

20-
const { groups: {relatedIssueNumber} } = isMatch
39+
const { groups: { issue } } = isMatch
2140

22-
core.info(`Auto-labeling related issue ${relatedIssueNumber} for release`)
41+
try {
42+
core.info(`Auto-labeling related issue ${issue} for release`)
2343
return await github.rest.issues.addLabels({
24-
issue_number: relatedIssueNumber,
44+
issue_number: issue,
2545
owner: context.repo.owner,
2646
repo: context.repo.repo,
27-
labels: [releaseLabel]
47+
labels: [LABEL_PENDING_RELEASE]
2848
})
29-
}
49+
} catch (error) {
50+
core.setFailed(`Is this issue number (${issue}) valid? Perhaps a discussion?`);
51+
throw new Error(error);
52+
}
53+
}

0 commit comments

Comments
 (0)