Edits history of script submission #23194 for ' Create Issue (github)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    /**
     * Create Issue
     * Open an issue in a repository, optionally with assignees, labels and a milestone.
     */
    export async function main(
      auth: RT.Github,
      owner: string,
      repo: string,
      title: string,
      body: string | undefined,
      assignees: string[] | undefined,
      labels: string[] | undefined,
      milestone: number | undefined
    ) {
      const response = await fetch(
        `https://api.github.com/repos/${owner}/${repo}/issues`,
        {
          method: "POST",
          headers: {
            Authorization: `Bearer ${auth.token}`,
            "Content-Type": "application/json",
            Accept: "application/vnd.github+json",
            "X-GitHub-Api-Version": "2022-11-28",
          },
          body: JSON.stringify({ title, body, assignees, labels, milestone }),
        }
      )
    
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`)
      }
    
      return await response.json()
    }
    

    Submitted by hugo989 2 hours ago