Skip to content

Commit

Permalink
Merge pull request #2 from notarize/releases/v7
Browse files Browse the repository at this point in the history
Releases/v7
  • Loading branch information
nedlehman committed Mar 11, 2022
2 parents 05b1cac + af6a699 commit 65e2a18
Show file tree
Hide file tree
Showing 563 changed files with 84,826 additions and 66,231 deletions.
28 changes: 18 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,25 @@ async function run() {
}

const title = github.context.payload.pull_request.title;
core.info(title);
const isAdhoc = title.includes('ADHOC') || title.includes('STORYBOOK');
if (isAdhoc) {
core.warning("PR is adhoc or storybook -- no updates made");
core.info("PR is adhoc or storybook -- no updates made");
return;
}

const jiraTicketKey = title.match(new RegExp("/(\w+-\d+)/"))[0];
core.info(title);
const matches = title.match(/(\w+-\d+)/)
if (!(matches)) {
core.warning("Jira ticket not in PR title");
return;
}
const jiraTicketKey = matches[0];
core.info(`Jira Ticket Key: ${jiraTicketKey}`);
const body = github.context.payload.pull_request.body;
if (body.contains(`https://notarize.atlassian.net/browse/${jiraTicketKey}`)) {
core.warning('PR body is prefixed already - no updates made');
core.info(body);
if (body.includes(jiraTicketKey)) {
core.info('PR body is prefixed already - no updates made');
return;
}

Expand All @@ -29,15 +37,15 @@ async function run() {
pull_number: github.context.payload.pull_request.number,
}

linkRegex = /(?m)^(?=.*?\bJIRA\b)(?=.*?\bticket\b).*$/
linkRegex = /^(?=.*?\bJIRA\b)(?=.*?\bticket\b).*$/m
lineToAdd = `:ticket: [JIRA ticket](https://notarize.atlassian.net/browse/${jiraTicketKey})`
lineExists = body.match(new RegExp(linkRegex))
if (lineExists.length > 0) {
lineExists = body.match(linkRegex)
if (lineExists) {
core.info("Line exists in PR body without ticket");
request.body = body.replace(new RegExp(linkRegex), lineToAdd)
request.body = body.replace(linkRegex, lineToAdd)
} else {
core.info("Adding line to PR body");
request.body = lineToAdd.contact('\n', body);
request.body = lineToAdd.concat('\n', body);
}

core.debug(`new body: ${request.body}`)
Expand All @@ -56,4 +64,4 @@ async function run() {
}
}

run()
run()
1 change: 1 addition & 0 deletions node_modules/.bin/acorn

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 65e2a18

Please sign in to comment.