forked from creatorsgarten/configuration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlib.ts
54 lines (50 loc) · 1.4 KB
/
lib.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import * as github from '@pulumi/github'
/**
* Invite a GitHub user into the organization.
* @param username - The username of the user to invite.
*/
export const creator = (username: string) =>
new github.TeamMembership(`membership-for-${username}`, {
teamId: '6011674',
username,
})
/**
* Creates a team on the GitHub organization.
* @param key - A unique key for the team.
* @param options - The options. Please specify `name` and `description`.
* @returns An object representing the team.
*/
export const team = (key: string, options: github.TeamArgs): ITeam => {
const team = new github.Team(`team-${key}`, { privacy: 'closed', ...options })
return Object.assign(
(username: string) =>
new github.TeamMembership(`team-${key}-membership-for-${username}`, {
teamId: team.id,
username,
}),
{ key, team },
)
}
export interface ITeam {
/**
* Invite a GitHub user into the team.
*/
(username: string): github.TeamMembership
key: string
team: github.Team
}
/**
* Grant teams admin rights to a GitHub organization.
* @param name - The name of the repository.
* @param t - An object returned by the `team` function.
* @returns
*/
export const grantAdmin = (
name: string,
t: { key: string; team: github.Team },
) =>
new github.TeamRepository(`team-${t.key}-repo-${name}`, {
teamId: t.team.id,
repository: name,
permission: 'admin',
})