Skip to content

Commit

Permalink
rollback
Browse files Browse the repository at this point in the history
  • Loading branch information
hspitzley-czi committed Oct 2, 2024
1 parent a9fcc1e commit f145524
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions .github/actions/jira-validate-reference/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |
the PR body (or update the existing summary if it already exists).
inputs:
projectKeys:
projectKey:
description: The Jira project keys to look for (comma delimited)
required: true
type: string
Expand Down Expand Up @@ -68,34 +68,26 @@ runs:
script: |
const prBody = ${{ steps.getPullRequest.outputs.prBody }};
const prTitle = ${{ steps.getPullRequest.outputs.prTitle }};
const projectKeys = `${{ inputs.projectKeys }}`.split(',').map(env => env.trim()).filter(b => b.length > 0);
if (projectKeys.length === 0) {
throw new Error('No projectKeys provided');
}
const issueRegexes = projectKeys.map(projectKey => new RegExp(`${projectKey}-\\d+`));
let jiraIssueRef = null;
const issueRegex = new RegExp(`${{ inputs.projectKey }}-\\d+`);
[
{ label: 'branch', value: '${{ github.head_ref }}' },
{ label: 'title', value: prTitle },
{ label: 'body', value: prBody },
].find(({label, value}) => {
const found = issueRegexes.find(issueRegex => {
const match = value.match(issueRegex);
if (match) {
jiraIssueRef = match[0];
console.log(`Found Jira issue reference in PR ${label}: ${jiraIssueRef}`);
return true;
}
return false;
});
return found;
const match = value.match(issueRegex);
if (match) {
jiraIssueRef = match[0];
console.log(`Found Jira issue reference in PR ${label}: ${jiraIssueRef}`);
return true;
}
return false;
});
const ownerAndRepo = '${{ github.repository }}';
const [owner, repo] = ownerAndRepo.split('/');
const noJiraIssueBody = `No Jira issue reference found in branch, title, or body of PR.\n\nPlease add a reference to a Jira issue in the form of PROJECTKEY-#### (eg: ${projectKeys[0]}-1234) to the branch name, title, or body of your PR.`;
const noJiraIssueBody = `No Jira issue reference found in branch, title, or body of PR.\n\nPlease add a reference to a Jira issue in the form of ${{ inputs.projectKey }}-#### (eg: ${{ inputs.projectKey }}-1234) to the branch name, title, or body of your PR.`;
const { data: comments } = await github.rest.issues.listComments({
owner,
Expand Down Expand Up @@ -149,10 +141,10 @@ runs:
- name: Find Jira Marker
id: findJiraMarker
if: steps.checkIfJobShouldRun.outputs.result == 'true'
uses: chanzuckerberg/github-actions/.github/actions/jira-find-marker@885251a38b81dbb9b6ab0b106dc31ec2f5703764
uses: chanzuckerberg/github-actions/.github/actions/jira-find-marker@a9fcc1eebdf68758ed741a0828e1c822a3b3177e
with:
pullRequestBody: ${{ steps.getPullRequest.outputs.prBody }}
projectKeys: ${{ inputs.projectKeys }}
projectKey: ${{ inputs.projectKey }}

- name: Update PR Body
uses: actions/github-script@v7
Expand Down

0 comments on commit f145524

Please sign in to comment.