Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed teams support #21

Merged
merged 5 commits into from
Jan 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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