1
Create Issue
One script reply has been approved by the moderators Verified
Created by saskiablueeyes19 696 days ago Viewed 5841 times
0
Submitted by adam186 Deno
Verified 393 days ago
1
import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
2

3
/**
4
 * @param owner The account owner of the repository. The name is not case sensitive.
5
 *
6
 * @param repo The name of the repository. The name is not case sensitive.
7
 *
8
 * @param title The title of the new issue.
9
 *
10
 * @param body The body of the new issue.
11
 *
12
 * @param assignees Logins for Users to assign to this issue.
13
 * *NOTE*: Only users with push access can set assignees for new issues.
14
 * Assignees are silently dropped otherwise.
15
 *
16
 * @param milestone The number of the milestone to associate this issue with.
17
 * *NOTE*: Only users with push access can set the milestone for new issues.
18
 * The milestone is silently dropped otherwise.
19
 *
20
 * @param labels Labels to associate with this issue.
21
 * *NOTE*: Only users with push access can set labels for new issues.
22
 * Labels are silently dropped otherwise.
23
 */
24
type Github = {
25
  token: string;
26
};
27
export async function main(
28
  gh_auth: Github,
29
  owner: string,
30
  repo: string,
31
  title: string,
32
  body: string,
33
  assignees?: string[],
34
  milestone?: string | number,
35
  labels?: string[]
36
) {
37
  const octokit = new Octokit({ auth: gh_auth.token });
38

39
  return await octokit.request("POST /repos/{owner}/{repo}/issues", {
40
    owner,
41
    repo,
42
    title,
43
    body,
44
    assignees: assignees || [],
45
    milestone,
46
    labels,
47
    headers: {
48
      "X-GitHub-Api-Version": "2022-11-28",
49
      Accept: "application/vnd.github+json",
50
    },
51
  });
52
}
53

Other submissions