Skip to content

Commit

Permalink
chore: refactor code to make 'in-review-column-id' optional
Browse files Browse the repository at this point in the history
  • Loading branch information
IKatsuba committed Dec 7, 2023
1 parent fa95630 commit 84d2c7d
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ inputs:
required: true
in-review-column-id:
description: 'Move to column id'
required: true
required: false

runs:
using: node20
Expand Down
12 changes: 8 additions & 4 deletions src/implemetation/add-pr-to-the-project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import { context } from '@actions/github';
import { getOctokit } from './octokit';

export async function addPrToTheProject(): Promise<void> {
const columnId = core.getInput('in-review-column-id');

if (!columnId) {
core.info('No column id provided, skipping');
return;
}

await getOctokit().rest.projects.createCard({
column_id: parseInt(
core.getInput('in-review-column-id', { required: true }),
10,
),
column_id: parseInt(columnId, 10),
content_id: context.issue.number,
content_type: 'PullRequest',
});
Expand Down
9 changes: 8 additions & 1 deletion src/implemetation/move-issue-to-in-review.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ import { getOctokit } from './octokit';
export async function moveIssueToInReview(issueNumber: number): Promise<void> {
core.info(`Move issue #${issueNumber} to In Review`);

const columnId = core.getInput('in-review-column-id');

if (!columnId) {
core.info('No column id provided, skipping');
return;
}

await getOctokit().graphql(
`
mutation ($columnId: ID!, $cardId: ID!) {
Expand All @@ -13,7 +20,7 @@ export async function moveIssueToInReview(issueNumber: number): Promise<void> {
}
`,
{
columnId: core.getInput('in-review-column-id', { required: true }),
columnId,
cardId: await getCardId(issueNumber),
},
);
Expand Down

0 comments on commit 84d2c7d

Please sign in to comment.