generated from actions/typescript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
44 lines (36 loc) · 1.3 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as core from '@actions/core';
import { addLabelsFromIssueToPR } from './implemetation/add-labels-from-issue-to-pr';
import {
addPrToTheProject,
movePRToInReviewStatus,
} from './implemetation/add-pr-to-the-project';
import { getLinkedIssues } from './implemetation/get-linked-issues';
import { moveIssueToInReviewStatus } from './implemetation/move-issue-to-in-review-status';
export async function run(): Promise<void> {
try {
core.info('Try to find linked issues');
const linkedIssues = await getLinkedIssues();
core.info(`Found ${linkedIssues.length} linked issues`);
for (const issue of linkedIssues) {
await core.group(`Sync issue #${issue.number} with PR`, async () => {
core.info(`#${issue.number} ${issue.title}`);
await addLabelsFromIssueToPR(issue.number);
await moveIssueToInReviewStatus(issue.number);
});
}
if (!linkedIssues.length) {
core.info('No linked issues found');
await core.group('Sync PR with project', async () => {
const itemId = await addPrToTheProject();
if (itemId) {
await movePRToInReviewStatus(itemId);
}
});
}
} catch (error) {
// Fail the workflow run if an error occurs
if (error instanceof Error) {
core.setFailed(error.message);
}
}
}