Skip to content

Commit

Permalink
Merge pull request #21 from pozil/teams
Browse files Browse the repository at this point in the history
Fixed teams support
  • Loading branch information
pozil authored Jan 17, 2022
2 parents 35c57ab + b48bf6f commit 9c72916
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
| `teams` | only if `assignees` is not specified | Comma separated list of teams. Issue will be assigned to the team members. |
| `numOfAssignee` | false | Number of assignees that will be randomly picked from the teams or assignees. If not specified, assigns all users. |

**Important Requirement**
If using the `teams` input parameter, you need to use a personal access token with `read:org` scope (the default `GITHUB_TOKEN` is not enough).

## Examples

Here's an example flow that auto-assigns all new issues to two users randomly chosen from `octocat`, `cat` and `dog` :
Expand Down Expand Up @@ -38,6 +41,7 @@ This other configuration assigns issues to a random member of the `support` team
- name: 'Auto-assign issue'
uses: pozil/auto-assign-issue@v1.3.0
with:
repo-token: ${{ secrets.MY_PERSONAL_ACCESS_TOKEN }}
teams: support
numOfAssignee: 1
```
Expand Down
4 changes: 2 additions & 2 deletions src/__tests__/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ const {
} = require('../action.js');

const TEAMS_MEMBERS = {
teamA: [{ login: 'userA1' }, { login: 'userA2' }],
teamB: [{ login: 'userB1' }]
teamA: { data: [{ login: 'userA1' }, { login: 'userA2' }] },
teamB: { data: [{ login: 'userB1' }] }
};
const CONTEXT_PAYLOAD = {
repository: { full_name: 'mockOrg/mockRepo' },
Expand Down
1 change: 1 addition & 0 deletions src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const getTeamMembers = async (octokit, org, teamNames) => {
throw newErr;
});
return teamMemberRequests
.map((response) => response.data)
.reduce((all, cur) => all.concat(cur), [])
.map((user) => user.login);
};
Expand Down

0 comments on commit 9c72916

Please sign in to comment.