diff --git a/.github/workflows/dev_pr/helpers.js b/.github/workflows/dev_pr/helpers.js index 520ff353291da..282567f956634 100644 --- a/.github/workflows/dev_pr/helpers.js +++ b/.github/workflows/dev_pr/helpers.js @@ -40,9 +40,9 @@ function detectIssue(title) { if (matched_jira) { return {"kind": "jira", "id": matched_jira[2]}; } - const matched_gh = /^(WIP:?\s*)?(GH-)(\d+)/.exec(title); + const matched_gh = /^(WIP:?\s*)?GH-(\d+)/.exec(title); if (matched_gh) { - return {"kind": "github", "id": matched_gh[3]}; + return {"kind": "github", "id": matched_gh[2]}; } return null; } diff --git a/.github/workflows/dev_pr/issue_check.js b/.github/workflows/dev_pr/issue_check.js index 9431fa7c9ecc9..87914f733f37c 100644 --- a/.github/workflows/dev_pr/issue_check.js +++ b/.github/workflows/dev_pr/issue_check.js @@ -138,19 +138,7 @@ async function assignGitHubIssue(github, context, pullRequestNumber, issueInfo) */ async function verifyGitHubIssue(github, context, pullRequestNumber, issueID) { const issueInfo = await helpers.getGitHubInfo(github, context, issueID, pullRequestNumber); - if (issueInfo) { - if (!issueInfo.assignees.length) { - await assignGitHubIssue(github, context, pullRequestNumber, issueInfo); - } - if(!issueInfo.labels.length) { - await github.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - body: ":warning: GitHub issue #" + issueID + " **has no labels in GitHub**, please add labels for components." - }) - } - } else { + if (!issueInfo) { await github.issues.createComment({ owner: context.repo.owner, repo: context.repo.repo, @@ -158,6 +146,17 @@ async function verifyGitHubIssue(github, context, pullRequestNumber, issueID) { body: ":x: GitHub issue #" + issueID + " could not be retrieved." }) } + if (!issueInfo.assignees.length) { + await assignGitHubIssue(github, context, pullRequestNumber, issueInfo); + } + if(!issueInfo.labels.filter((label) => label.startsWith("Component:")).length) { + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pullRequestNumber, + body: ":warning: GitHub issue #" + issueID + " **has no components**, please add labels for components." + }) + } } module.exports = async ({github, context}) => { diff --git a/.github/workflows/dev_pr/link.js b/.github/workflows/dev_pr/link.js index fb58208f7a3a2..7d99ca105312b 100644 --- a/.github/workflows/dev_pr/link.js +++ b/.github/workflows/dev_pr/link.js @@ -56,16 +56,19 @@ async function haveComment(github, context, pullRequestNumber, message) { * @param {String} jiraID */ async function commentJIRAURL(github, context, pullRequestNumber, jiraID) { + const issueInfo = await helpers.getJiraInfo(jiraID); const jiraURL = `https://issues.apache.org/jira/browse/${jiraID}`; if (await haveComment(github, context, pullRequestNumber, jiraURL)) { return; } - await github.issues.createComment({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: pullRequestNumber, - body: jiraURL - }); + if (issueInfo){ + await github.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: pullRequestNumber, + body: jiraURL + }); + } } /**