-
-
Notifications
You must be signed in to change notification settings - Fork 777
/
add-team-member.js
27 lines (25 loc) · 1018 Bytes
/
add-team-member.js
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
/**
* Function to return list of current team members
* @param {Object} github - github object from actions/github-script
* @param {Object} context - context object from actions/github-script
* @param {String} team - team to check for member
* @param {String} username - member to check for team membership
*/
async function addTeamMember(github, context, team, username){
const baseMember = await github.request('GET /orgs/{org}/teams/{team_slug}/memberships/{username}', {
org: context.repo.owner,
team_slug: team,
username: username,
});
// If response status is not 200, need to add member to baseTeam
if(baseMember.status != 200){
await github.request('PUT /orgs/{org}/teams/{team_slug}/memberships/{username}', {
org: context.repo.owner,
team_slug: team,
username: username,
role: 'member',
});
console.log('Member added to \'' + team + '\' team: ' + username);
}
}
module.exports = addTeamMember;