Skip to content

Commit

Permalink
Require passing github token
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Nied <[email protected]>
  • Loading branch information
peternied committed Oct 17, 2023
1 parent 9ea05a9 commit 0c09097
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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'
Expand All @@ -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: ''
Expand All @@ -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'
Expand All @@ -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'
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -23,6 +26,7 @@ on:
steps:
- uses: peternied/approved-by-maintainers@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
min-required: 1
```
Expand Down
5 changes: 4 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit 0c09097

Please sign in to comment.