Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Enforce PR approvals

on:
pull_request:
branches:
- main

jobs:
require-approval:
runs-on: ubuntu-latest
steps:
- name: Check if PR has approvals
uses: actions/github-script@v7
with:
script: |
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const approvals = reviews.filter(r => r.state === "APPROVED");
Comment thread
aleksfasting marked this conversation as resolved.
if (approvals.length < 1) {
core.setFailed("[ERROR]: This PR needs at least 1 approval before merging.");
} else {
console.log("[Passed]: At least 1 approval found.");
}