Skip to content

Minor next

Minor next #45

#For PRs made by collaborators, this means 1 reviewer + the author.
#We trust that collaborators don't need as much oversight.
name: Auto approve collaborator PRs
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
- pull_request_review
jobs:
dispatch:
name: Request approval
runs-on: ubuntu-latest
if: '! github.event.pull_request.draft'
steps:
- name: Generate access token
id: generate-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.RESTRICTED_ACTIONS_DISPATCH_ID }}
private-key: ${{ secrets.RESTRICTED_ACTIONS_DISPATCH_KEY }}
owner: ${{ github.repository_owner }}
repositories: RestrictedActions
- name: "Check if bot's review was dismissed (pull_request_review.dismissed only )"
if: ${{ github.event.payload.action == 'dismissed' }}
id: re-review
env:
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
run: |
user_id=$(gh api "/app/installations/${{ steps.generate-token.outputs.installation-id }}" --jq .account.id)"
if [[ "$user_id" != "${{ github.event.payload.user.id }}" ]]; then
echo "Not the bot's review that was dismissed (${{ github.event.payload.user.login }})"
echo "skip=true" >> $GITHUB_OUTPUT
else
echo "skip=false" >> $GITHUB_OUTPUT
fi
- name: Dispatch restricted action
if: ${{ steps.re-review.outputs.skip != 'false' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ steps.generate-token.outputs.token }}
repository: ${{ github.repository_owner }}/RestrictedActions
event-type: auto_approve_collaborator_pr
client-payload: '{"repo": "${{ github.repository }}", "pull_request_id": "${{ github.event.pull_request.number }}" }'