Create an organization invitation

(Description borrowed from official documentation at https://github.com/octokit/plugin-rest-endpoint-methods.js/blob/master/docs/orgs/createInvitation.md) --- Invite people to an organization by using their GitHub user ID or their email address. In order to create invitations in an organization, the authenticated user must be an organization owner.

Script github

by lplit ยท 8/26/2022

  • Submitted by lplit Deno
    Created 1352 days ago
    1
    import * as wmill from "https://deno.land/x/[email protected]/mod.ts";
    2
    import { Octokit } from "https://cdn.skypack.dev/octokit?dts";
    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
    */
    11
    
    
    12
    export async function main(
    13
      gh_auth: wmill.Resource<"github">,
    14
      organizationName: string,
    15
      inviteeId: string,
    16
      email: string,
    17
      role?: "admin" | "direct_member" | "billing_manager",
    18
      teamIds?: string,
    19
    ) {
    20
      const octokit = new Octokit(gh_auth);
    21
      const response = await octokit.rest.orgs.createInvitation({
    22
        org: organizationName,
    23
        invitee_id: inviteeId,
    24
        email: email,
    25
        role: role,
    26
        team_ids: teamIds,
    27
      });
    28
    
    
    29
      return response;
    30
    }
    31