Skip to content

Commit

Permalink
EDIT: Fetching issues after fetching project
Browse files Browse the repository at this point in the history
  • Loading branch information
erichjsonfosse committed Aug 14, 2024
1 parent 3592daf commit 65548e3
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 26 deletions.
19 changes: 10 additions & 9 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

15 changes: 2 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as core from '@actions/core';
import * as gitUtils from './git-utils';
import { WrappedJiraClient } from './wrapped-jira-client';
import { JiraIssue } from 'ts-jira-client/lib/custom';

/**
* The main function for the action.
Expand All @@ -20,9 +19,6 @@ export async function run(): Promise<void> {
}
core.debug(`Tag: ${tag}`);

const tagMessage = await gitUtils.findTagMessage(tag);
core.debug(`Tag message: '${tagMessage}'`);

let jiraApiVersion: 1 | 2 | 3 = 3;
const c = parseInt(core.getInput('jira_api_version'), 10);
if (validateJiraApiVersion(c)) {
Expand All @@ -39,17 +35,10 @@ export async function run(): Promise<void> {
}
});

let issues: JiraIssue[] = [];
if (null !== tagMessage) {
issues = await wrappedJiraClient.findIssuesInString(tagMessage);
}

core.debug(`Found ${issues.length} issue${issues.length ? '' : 's'}`);

await wrappedJiraClient.createVersionWithIssues(
await wrappedJiraClient.createVersion(
core.getInput('jira_project'),
tag,
issues
tag
);
} catch (error) {
if (error instanceof Error) {
Expand Down
17 changes: 14 additions & 3 deletions src/wrapped-jira-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as core from '@actions/core';
import { JiraIssue, JiraProject } from 'ts-jira-client/lib/custom';
import { components } from 'ts-jira-client/lib/generated/openapi-cloud';
import { AxiosError } from 'axios';
import * as gitUtils from './git-utils';

type JiraProjectVersion = components['schemas']['Version'];

Expand All @@ -23,10 +24,10 @@ export class WrappedJiraClient {
this.jiraApi = new JiraApi(options.jira);
}

async createVersionWithIssues(
async createVersion(
projectKey: string,
name: string,
issues: JiraIssue[]
tag: string,
name: string
): Promise<void> {
let project: JiraProject | null = null;

Expand Down Expand Up @@ -76,6 +77,16 @@ export class WrappedJiraClient {

core.debug(`Created version: ${version.name}`);

const tagMessage = await gitUtils.findTagMessage(tag);
core.debug(`Tag message: '${tagMessage}'`);

let issues: JiraIssue[] = [];
if (null !== tagMessage) {
issues = await this.findIssuesInString(tagMessage);
}

core.debug(`Found ${issues.length} issue${issues.length > 1 ? 's' : ''}`);

for (const issue of issues) {
try {
await this.jiraApi.updateIssue(issue.id, {
Expand Down

0 comments on commit 65548e3

Please sign in to comment.