From bdb406d4832af5715a36c11032333c4191511305 Mon Sep 17 00:00:00 2001 From: Artemii Gerasimovich Date: Thu, 22 Aug 2024 17:20:01 +0200 Subject: [PATCH 1/2] Don't assign people to drafts --- .github/workflows/assign-reviewers.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/assign-reviewers.yml b/.github/workflows/assign-reviewers.yml index 2bc972cd65..640dfe99d2 100644 --- a/.github/workflows/assign-reviewers.yml +++ b/.github/workflows/assign-reviewers.yml @@ -6,14 +6,21 @@ on: jobs: test: runs-on: ubuntu-latest + if: github.event.pull_request.draft == false steps: - name: Choose random assignees run: | + # Skip PRs that have assignees already + gh pr view ${{ github.event.number }} --repo ${{ github.repository }} --json assignees \ + | jq '.assignees | length > 0' -e && \ + exit 0 + chosen=$(perl \ -e 'use List::Util qw(shuffle head);' \ -e 'my @assignees = grep { "${{ github.event.actor }}" ne $_ } shuffle split /\s+/, $ENV{ASSIGNEES};' \ -e 'print join ",", head $ENV{NUM_ASSIGNEES}, @assignees' \ ) + gh pr edit ${{ github.event.number }} --add-assignee $chosen --repo ${{ github.repository }} env: GITHUB_TOKEN: ${{ github.token }} From 3527cfdc104f61ea90fb184b1974394b84a75c26 Mon Sep 17 00:00:00 2001 From: Artemii Gerasimovich Date: Thu, 22 Aug 2024 17:28:21 +0200 Subject: [PATCH 2/2] Fix PR author --- .github/workflows/assign-reviewers.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/assign-reviewers.yml b/.github/workflows/assign-reviewers.yml index 640dfe99d2..042161a3e1 100644 --- a/.github/workflows/assign-reviewers.yml +++ b/.github/workflows/assign-reviewers.yml @@ -17,7 +17,7 @@ jobs: chosen=$(perl \ -e 'use List::Util qw(shuffle head);' \ - -e 'my @assignees = grep { "${{ github.event.actor }}" ne $_ } shuffle split /\s+/, $ENV{ASSIGNEES};' \ + -e 'my @assignees = grep { "${{ github.event.sender.login }}" ne $_ } shuffle split /\s+/, $ENV{ASSIGNEES};' \ -e 'print join ",", head $ENV{NUM_ASSIGNEES}, @assignees' \ )