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

Feature toggle for round-robin assignment #11

Closed
plowin opened this issue Dec 20, 2022 · 6 comments · Fixed by #13
Closed

Feature toggle for round-robin assignment #11

plowin opened this issue Dec 20, 2022 · 6 comments · Fixed by #13
Assignees
Labels
enhancement New feature or request

Comments

@plowin
Copy link

plowin commented Dec 20, 2022

Hi nice workflow which we would like to use with an additional functionality:
When specifying a team as either reviewer or assignee and then configure numberOfAssignees, it always take the first user from the list. It would be nice to have some round-robin functionality here.

Expected Behavior

Have a feature-toggle like randomReviewers and randomAssignees that can be set to true to assign random ppl from the team or list of people.

Possible Solution

Some changes around

teams: sampleSize(teams, count),

@bubkoo
Copy link
Member

bubkoo commented Dec 21, 2022

Hi @plowin Thanks for opening your issue here!

The code here using lodash's sampleSize method to randomly pick count user from teams. So it already has random functionality.

It would be very helpful if you could provide the contents of your workflow.

@plowin
Copy link
Author

plowin commented Dec 21, 2022

Hi, thanks a lot for the quick reply!
With a team of 3-4 people, it is probably very unlikely to always have the same assignee:
image

My workflow is here, I tried using a team even though this is not documented:

    steps:
      - uses: wow-actions/auto-assign@v2
        with:
          GITHUB_TOKEN: ${{ secrets.TEST_TOKEN }}
          reviewers: org-plowin/team-plowin
          assignees: org-plowin/team-plowin # b1tamara,plowin,stefanlay
          numberOfReviewers: 1
          numberOfAssignees: 1
          skipKeywords: wip, draft

@bubkoo bubkoo self-assigned this Dec 22, 2022
@bubkoo
Copy link
Member

bubkoo commented Dec 22, 2022

@plowin
I catch the issue. Adding a team to assignees is not supported by GitHub. So I'm trying to fetch the members of a team, then add the members as assignees in this PR.

In order to test the action I create a team "authors" with two members: "bubkoo" and "srm-bot". And update my test workflow with:

        with:
          GITHUB_TOKEN: ${{ env.BOT_TOKEN }}
          addReviewers: true
          addAssignees: true
          numberOfReviewers: 1
          numberOfAssignees: 1
          reviewers: |
            /authors
          assignees: |
            this-is-an-unknown-assignee
            /authors
          skipKeywords: wip
          excludeLabels: dependencies, wip

The result looks like what you'd expect.

image

Note that the default ${{ secrets.GITHUB_TOKEN }} does not have the permission to add teams as reviewers or to list members of a team. As a workaround:

  • First, create a personal access token (PAT) with repo and admin:org permissions.
  • Then, make the PAT available to our actions by adding the token as a secret.
  • Finally, replace the GITHUB_TOKEN with the new secret, e.g. GITHUB_TOKEN: ${{ secrets.NAME_OF_MY_SECRET_CONTAINING_PAT_WITH_REPO_ACCESS }} instead of GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}.

Or with a cool but slightly cumbersome solution: create a private github app for your org with custom permissions and avatar, then use the app token in out workflow, e.g. wow-actions-bot.

@plowin
Copy link
Author

plowin commented Jan 2, 2023

cool, I'll try it out once you release a v3!

@bubkoo bubkoo closed this as completed in #13 Jan 3, 2023
plowin added a commit to org-plowin/code-review-poc that referenced this issue Jan 4, 2023
plowin added a commit to org-plowin/code-review-poc that referenced this issue Jan 4, 2023
@plowin
Copy link
Author

plowin commented Jan 4, 2023

Hi, in my test-action I tried multiple variations and in the end even copied the exact action you pasted above but I keep getting the same error:

runTypeError: Cannot read properties of undefined (reading 'length')
--
runCannot read properties of undefined (reading 'length')

I am not familiar with debugging GH actions and error output does not help a lot here. v2 worked with the variations I tried.

The GH history of this file shows you what I tried, they all fail with the exact same error. The PAT has org:admin scope.

bubkoo added a commit that referenced this issue Jan 30, 2023
github-actions bot pushed a commit that referenced this issue Jan 30, 2023
## [3.0.2](v3.0.1...v3.0.2) (2023-01-30)

### Bug Fixes

* try to fix "Cannot read properties of undefined (reading 'length')" ([48e18c6](48e18c6)), closes [#11](#11)
@bubkoo
Copy link
Member

bubkoo commented Jan 30, 2023

@plowin v3.0.2 was released. Try to rerun your workflow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants