-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
34 lines (29 loc) · 994 Bytes
/
index.js
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
import * as core from "@actions/core";
import * as github from "@actions/github";
import { proposeLabels } from "./ai.js";
try {
const apiKey = core.getInput("openai-api-key");
const githubToken = core.getInput("github-token");
const octokit = github.getOctokit(githubToken);
const issue = await octokit.rest.issues.get({
...github.context.issue,
issue_number: github.context.issue.number,
});
const availableLabels = await octokit.rest.issues.listLabelsForRepo({
...github.context.repo,
});
const labels = await proposeLabels(issue.data, availableLabels.data, { apiKey, logger: core } );
core.debug(labels)
if (labels.length > 0) {
await octokit.rest.issues.setLabels({
owner: github.context.issue.owner,
repo: github.context.issue.repo,
issue_number: github.context.issue.number,
labels
})
} else {
core.setFailed('Failed to propose labels')
}
} catch (error) {
core.setFailed(`Error Message: ${error.stack}`);
}