From 0c09097af5dbe2dfe0ff5941b5882aa3ee534378 Mon Sep 17 00:00:00 2001 From: Peter Nied Date: Tue, 17 Oct 2023 06:27:42 -0500 Subject: [PATCH] Require passing github token Signed-off-by: Peter Nied --- .github/workflows/test.yml | 5 +++++ README.md | 4 ++++ action.yml | 5 ++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a171757..07884bf 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -13,6 +13,7 @@ jobs: - id: approved-by-maintainers uses: ./ # Use the action with: + token: ${{ secrets.GITHUB_TOKEN }} maintainers-file: ./MAINTAINERS-Simple.md min-required: 1 mock-approvers: 'peternied' @@ -28,6 +29,7 @@ jobs: - id: approved-by-maintainers uses: ./ # Use the action with: + token: ${{ secrets.GITHUB_TOKEN }} maintainers-file: ./MAINTAINERS-Simple.md min-required: 1 mock-approvers: 'peternied greengiant' @@ -43,6 +45,7 @@ jobs: - id: approved-by-maintainers uses: ./ # Use the action with: + token: ${{ secrets.GITHUB_TOKEN }} maintainers-file: ./MAINTAINERS-Simple.md min-required: 1 mock-approvers: '' @@ -58,6 +61,7 @@ jobs: - id: approved-by-maintainers uses: ./ # Use the action with: + token: ${{ secrets.GITHUB_TOKEN }} maintainers-file: ./MAINTAINERS-Simple.md min-required: 1 mock-approvers: 'greengiant' @@ -73,6 +77,7 @@ jobs: - id: approved-by-maintainers uses: ./ # Use the action with: + token: ${{ secrets.GITHUB_TOKEN }} maintainers-file: ./MAINTAINERS-Simple.md min-required: 2 mock-approvers: 'peternied' diff --git a/README.md b/README.md index 75e0259..dce4a52 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,9 @@ Github action to verify that maintainers have approved this PR ```yaml inputs: + token: + description: "GitHub token used for authentication" + required: true maintainers-file: description: 'The file where the maintainers are listed, defaults to MAINTAINERS.md' required: false @@ -23,6 +26,7 @@ on: steps: - uses: peternied/approved-by-maintainers@v1 with: + token: ${{ secrets.GITHUB_TOKEN }} min-required: 1 ``` diff --git a/action.yml b/action.yml index 574db5f..120fa08 100644 --- a/action.yml +++ b/action.yml @@ -3,6 +3,9 @@ name: 'Approved By Maintainers' description: 'Verifies that this pull request has been approved by maintainers' inputs: + token: + description: "GitHub token used for authentication" + required: true maintainers-file: description: 'The file where the maintainers are listed, defaults to MAINTAINERS.md' required: false @@ -32,7 +35,7 @@ runs: shell: bash - run: | - reviewers=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ + reviewers=$(curl -s -H "Authorization: token ${{ input.token }}" \ "https://api.github.com/repos/$GITHUB_REPOSITORY/pulls/${{ github.event.pull_request.number }}/reviews") approvers=$(echo "$reviewers" | jq -r '.[] | select(.state == "APPROVED") | .user.login')