|
1 | 1 | import { getInput, info, setFailed } from "@actions/core"; |
2 | 2 | import { context, getOctokit } from "@actions/github"; |
| 3 | + |
3 | 4 | import { CoreLogger } from "./github/CoreLogger"; |
4 | 5 | import { IssueApi } from "./github/issueKit"; |
5 | 6 | import { ProjectKit } from "./github/projectKit"; |
6 | 7 | import { GitHubContext, Synchronizer } from "./synchronizer"; |
7 | 8 |
|
8 | | - |
9 | | -//** Generates the class that will handle the project logic */ |
| 9 | +//* * Generates the class that will handle the project logic */ |
10 | 10 | const generateSynchronizer = (): Synchronizer => { |
11 | | - const repoToken = getInput("GITHUB_TOKEN", { required: true }); |
12 | | - const orgToken = getInput("PROJECT_TOKEN", { required: true }); |
| 11 | + const repoToken = getInput("GITHUB_TOKEN", { required: true }); |
| 12 | + const orgToken = getInput("PROJECT_TOKEN", { required: true }); |
13 | 13 |
|
14 | | - const projectNumber = parseInt(getInput("project", { required: true })); |
15 | | - // TODO: Add support for custom project fields (https://docs.github.com/en/issues/planning-and-tracking-with-projects/understanding-fields) |
| 14 | + const projectNumber = parseInt(getInput("project", { required: true })); |
| 15 | + // TODO: Add support for custom project fields (https://docs.github.com/en/issues/planning-and-tracking-with-projects/understanding-fields) |
16 | 16 |
|
17 | | - const { repo } = context; |
| 17 | + const { repo } = context; |
18 | 18 |
|
19 | | - const kit = getOctokit(repoToken); |
20 | | - const issueKit = new IssueApi(kit, repo); |
21 | | - const projectGraphQl = getOctokit(orgToken).graphql.defaults({ headers: { authorization: `token ${orgToken}` } }); |
22 | | - const logger = new CoreLogger(); |
23 | | - const projectKit = new ProjectKit(projectGraphQl, repo, projectNumber, logger); |
| 19 | + const kit = getOctokit(repoToken); |
| 20 | + const issueKit = new IssueApi(kit, repo); |
| 21 | + const projectGraphQl = getOctokit(orgToken).graphql.defaults({ headers: { authorization: `token ${orgToken}` } }); |
| 22 | + const logger = new CoreLogger(); |
| 23 | + const projectKit = new ProjectKit(projectGraphQl, repo, projectNumber, logger); |
24 | 24 |
|
25 | | - return new Synchronizer(issueKit, projectKit, logger); |
26 | | -} |
| 25 | + return new Synchronizer(issueKit, projectKit, logger); |
| 26 | +}; |
27 | 27 |
|
28 | 28 | const synchronizer = generateSynchronizer(); |
29 | 29 |
|
30 | 30 | const { issue } = context.payload; |
31 | 31 | const parsedContext: GitHubContext = { |
32 | | - eventName: context.eventName, |
33 | | - payload: { |
34 | | - inputs: context.payload.inputs, |
35 | | - issue: issue ? { |
36 | | - number: issue.number, |
37 | | - node_id: issue.node_id |
38 | | - } : undefined |
39 | | - } |
40 | | -} |
41 | | - |
42 | | -synchronizer.synchronizeIssue(parsedContext) |
43 | | - .then(() => info("Finished")) |
44 | | - .catch(setFailed); |
| 32 | + eventName: context.eventName, |
| 33 | + payload: { |
| 34 | + // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment |
| 35 | + inputs: context.payload.inputs, |
| 36 | + issue: issue ? { number: issue.number, node_id: issue.node_id as string } : undefined, |
| 37 | + }, |
| 38 | +}; |
| 39 | + |
| 40 | +synchronizer |
| 41 | + .synchronizeIssue(parsedContext) |
| 42 | + .then(() => info("Finished")) |
| 43 | + .catch(setFailed); |
0 commit comments