From abfb90e647f127d07bea42cb790063d0fc96ea01 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Wed, 6 Dec 2023 12:53:46 -0600 Subject: [PATCH] Require required approvers list Signed-off-by: Peter Nied --- .github/workflows/test.yml | 4 ++-- README.md | 5 +---- action.yml | 2 +- dist/index.js | 2 +- index.js | 2 +- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1d6b2eb..3d0b725 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -111,7 +111,7 @@ jobs: - if: steps.approved-by-required-users.outcome != 'failure' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied' run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}" - test-approved-by-anyone: + test-no-required-approvers-list: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -124,5 +124,5 @@ jobs: mock-approvers: 'peternied bob kelly' mock-pr-number: 42 - - if: steps.approved-by-required-users.outcome != 'failure' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied bob kelly' + - if: steps.approved-by-required-users.outcome != 'success' || steps.approved-by-required-users.outputs.maintainer-approvals != 'peternied bob kelly' run: echo "Unexpected outcome:${{ steps.approved-by-required-users.outcome }} or maintainer-approvals:${{steps.approved-by-required-users.outputs.maintainer-approvals}}" diff --git a/README.md b/README.md index 8613c04..ed1d4b1 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ inputs: required: true required-approvers-list: description: 'The list of specific users that can approve the request, comma seperated. ' - required: false + required: true min-required: description: 'The minimum number of approvals, e.g. 2' required: true @@ -24,9 +24,6 @@ outputs: ```yaml on: pull_request_review: - types: [approved] - pull_request_target: - types: [opened, reopened] ... steps: - id: list-maintainers diff --git a/action.yml b/action.yml index 446cc95..b725204 100644 --- a/action.yml +++ b/action.yml @@ -12,7 +12,7 @@ inputs: required: true required-approvers-list: description: 'The list of specific users that can approve the request, comma separated. ' - required: false + required: true min-required: description: 'The minimum number of approvals, e.g. 2' required: true diff --git a/dist/index.js b/dist/index.js index d7f78e1..0d488e1 100644 --- a/dist/index.js +++ b/dist/index.js @@ -36730,7 +36730,7 @@ async function run() { return; } - const requiredApprovers = core.getInput('required-approvers-list', { required: false })?.split(',').map(s => s.trim()) || []; + const requiredApprovers = core.getInput('required-approvers-list', { required: true })?.split(',').map(s => s.trim()).filter(a => a.length != 0); const mockApprovers = core.getInput('mock-approvers', { required: false })?.split(' ') || []; let pullRequestApprovers = mockApprovers; diff --git a/index.js b/index.js index d4deaaa..7a91315 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,7 @@ async function run() { return; } - const requiredApprovers = core.getInput('required-approvers-list', { required: false })?.split(',').map(s => s.trim()) || []; + const requiredApprovers = core.getInput('required-approvers-list', { required: true })?.split(',').map(s => s.trim()).filter(a => a.length != 0); const mockApprovers = core.getInput('mock-approvers', { required: false })?.split(' ') || []; let pullRequestApprovers = mockApprovers;