Create issue

Script gitlab

by saskiaostrmi ยท 6/6/2022

  • Submitted by lplit Deno
    Created 1333 days ago
    1
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    2
    /*
    3
    @param: {wmill.Resource<"gitlab">} glab - Resource containing Gitlab Auth API Key
    4
    Example:
    5
    {
    6
      auth: gitlab_api_key,
    7
      baseUrl: "https://www.gitlab.com" 
    8
    }
    9
    */
    10
    export async function main(
    11
      glab: wmill.Resource<"gitlab">,
    12
      projectId: string,
    13
      issueTitle: string,
    14
      issueDescription: string,
    15
    ) {
    16
      const url = `${glab.baseUrl}/api/v4/projects/${projectId}/issues`;
    17
      const issue = await fetch(`${url}`, {
    18
        method: "POST",
    19
        headers: {
    20
          "Authorization": `Bearer: ${glab.token}`,
    21
          "Content-Type": "application/json",
    22
        },
    23
        body: JSON.stringify({
    24
          "title": issueTitle,
    25
          "description": issueDescription,
    26
        }),
    27
      });
    28
      return await issue.json();
    29
    }