1

Create Issue

by
Published Jun 6, 2022
Script github Verified

The script

Submitted by hugo989 Bun
Verified 14 days ago
1
import { Octokit } from "@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
  • Submitted by rossmccrann Deno
    Created 1168 days ago
    1
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    2
    import { Octokit } from "https://cdn.skypack.dev/@octokit/rest";
    3
    
    
    4
    /*
    5
    @param: {wmill.Resource<"github">} gh_auth - Resource containing Github Auth API Key
    6
    example:
    7
    {
    8
        auth: github_api_key
    9
    }
    10
    @param: {string} owner - Github username of repo owner
    11
    @param: {string} repo - Github repo name
    12
    @param: {string} title - title of Github issue
    13
    @param: {string} body - body of Github issue
    14
    */
    15
    
    
    16
    export async function main(
    17
      gh_auth: wmill.Resource<"github">,
    18
      owner: string,
    19
      repo: string,
    20
      title: string,
    21
      body: string,
    22
    ) {
    23
      const octokit = new Octokit({ auth: gh_auth.token });
    24
    
    
    25
      const response = await octokit.rest.issues.create({
    26
        owner: owner,
    27
        repo: repo,
    28
        title: title,
    29
        body: body,
    30
      });
    31
    
    
    32
      return response;
    33
    }
    34
    
    
  • Submitted by adam186 Deno
    Created 406 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