From 6d4dfab712446e5158eeab129ad1f8bcc82c318c Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 28 Nov 2023 19:00:12 +0000 Subject: [PATCH 1/5] Add maintainer approval check Signed-off-by: Peter Nied --- .github/workflows/maintainer-approved.yml | 35 +++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/maintainer-approved.yml diff --git a/.github/workflows/maintainer-approved.yml b/.github/workflows/maintainer-approved.yml new file mode 100644 index 0000000000000..6f38968127bbd --- /dev/null +++ b/.github/workflows/maintainer-approved.yml @@ -0,0 +1,35 @@ +name: Check if maintainers have approved this PR + +on: + pull_request_review: + types: [submitted] + + pull_request_target: + types: [opened, reopened] + +jobs: + maintainer-approved-check: + runs-on: ubuntu-latest + steps: + - id: find-maintainers + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + const maintainersList = await github.request('GET /repos/{owner}/{repo}/collaborators', { + owner: 'peternied', + repo: 'OpenSearch-1', + permission: 'maintain', + affiliation: 'all', + per_page: 100 + }); + + console.log(JSON.stringify(maintainersList)); + return "a, b, c" + + - uses: peternied/approved-by-maintainers@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + min-required: 1 + maintainers: ${{ steps.find-maintainers.outputs.result }} From 47714af152ba7e17e0123f038118e222482cbf4e Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 28 Nov 2023 19:00:12 +0000 Subject: [PATCH 2/5] Add maintainer approval check Signed-off-by: Peter Nied --- .github/workflows/maintainer-approved.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/maintainer-approved.yml b/.github/workflows/maintainer-approved.yml index 6f38968127bbd..5a480852ddde4 100644 --- a/.github/workflows/maintainer-approved.yml +++ b/.github/workflows/maintainer-approved.yml @@ -9,7 +9,7 @@ on: jobs: maintainer-approved-check: - runs-on: ubuntu-latest + runs-on: ubunut-latest steps: - id: find-maintainers uses: actions/github-script@v7 @@ -17,9 +17,10 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} result-encoding: string script: | - const maintainersList = await github.request('GET /repos/{owner}/{repo}/collaborators', { - owner: 'peternied', - repo: 'OpenSearch-1', + const maintainersList = await github.request('GET GET /repos/{owner}/{repo}/collaborators', { + owner: 'OWNER', + repo: 'REPO', + repository_id: 'my-repoid', permission: 'maintain', affiliation: 'all', per_page: 100 From a528de85b9db878460d3eb33a7d7824927ca2541 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 28 Nov 2023 19:01:43 +0000 Subject: [PATCH 3/5] minor change Signed-off-by: Peter Nied --- .github/workflows/precommit.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml index cd75eb47946a4..d76ea8f970041 100644 --- a/.github/workflows/precommit.yml +++ b/.github/workflows/precommit.yml @@ -17,6 +17,6 @@ jobs: java-version: ${{ matrix.java }} distribution: temurin cache: gradle - - name: Run Gradle (precommit) + - name: Run Gradle (precommit) run: | ./gradlew javadoc precommit --parallel From 2dbd4e419d9e65384aa4de8c5cc29557a0333715 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 28 Nov 2023 19:00:12 +0000 Subject: [PATCH 4/5] Add maintainer approval check Signed-off-by: Peter Nied --- .github/workflows/maintainer-approved.yml | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 .github/workflows/maintainer-approved.yml diff --git a/.github/workflows/maintainer-approved.yml b/.github/workflows/maintainer-approved.yml new file mode 100644 index 0000000000000..56d98b848f12c --- /dev/null +++ b/.github/workflows/maintainer-approved.yml @@ -0,0 +1,34 @@ +name: Check if maintainers have approved this PR + +on: + pull_request_review: + types: [submitted] + + pull_request_target: + types: [opened, reopened] + +jobs: + maintainer-approved-check: + runs-on: ubuntu-latest + steps: + - id: find-maintainers + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + const maintainersResponse = await github.request('GET /repos/{owner}/{repo}/collaborators', { + owner: 'peternied', + repo: 'OpenSearch-1', + permission: 'maintain', + affiliation: 'all', + per_page: 100 + }); + + return maintainersResponse.data.map(item => item.login).join(', '); + + - uses: peternied/approved-by-maintainers@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + min-required: 1 + maintainers: ${{ steps.find-maintainers.outputs.result }} From ee6ac7379f4e58630a602ecfe0d7f4256620784d Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 28 Nov 2023 19:00:12 +0000 Subject: [PATCH 5/5] Add maintainer approval check Signed-off-by: Peter Nied --- .github/workflows/maintainer-approved.yml | 36 +++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/maintainer-approved.yml diff --git a/.github/workflows/maintainer-approved.yml b/.github/workflows/maintainer-approved.yml new file mode 100644 index 0000000000000..0c85671455bcf --- /dev/null +++ b/.github/workflows/maintainer-approved.yml @@ -0,0 +1,36 @@ +name: Maintainers approval + +on: + pull_request_review: + types: [submitted] + + pull_request_target: + types: [opened, reopened] + +jobs: + maintainer-approved-check: + name: Minimum approval count + runs-on: ubuntu-latest + steps: + - id: find-maintainers + uses: actions/github-script@v7 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + result-encoding: string + script: | + // Get the collaborators - filtered to maintainer permissions + const maintainersResponse = await github.request('GET /repos/{owner}/{repo}/collaborators', { + owner: context.repo.owner, + repo: context.repo.repo, + permission: 'maintain', + affiliation: 'all', + per_page: 100 + }); + + return maintainersResponse.data.map(item => item.login).join(', '); + + - uses: peternied/approved-by-maintainers@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + min-required: 1 + maintainers: ${{ steps.find-maintainers.outputs.result }}