Skip to content

Commit c191318

Browse files
authored
Simplify pr workflow to require 2 approvals on all PR's (#74)
Simplify pr workflow to require 2 approvals on all PR's ## Call Outs All PR's will need 2 approvals from the commitee for this check to pass. A more intelligent approach is on the way, but till then all PR's will need 2 approvals. This is done to prevent sneak attacks where someone gets approval for non-std related changes, and after approval, they make changes to the std files.
1 parent b588f71 commit c191318

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

.github/workflows/pr_approval.yml

-61
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ name: Check PR Approvals
77
on:
88
pull_request_review:
99
types: [submitted]
10-
workflow_dispatch:
11-
12-
# Without these permissions, we get a 403 error from github
13-
# for trying to modify the pull request for newer project.
14-
# Source: https://stackoverflow.com/a/76994510
15-
permissions: write-all
1610

1711
jobs:
1812
check-approvals:
@@ -51,22 +45,6 @@ jobs:
5145
pull_number = context.issue.number;
5246
}
5347
54-
// Get PR files
55-
const files = await github.rest.pulls.listFiles({
56-
owner,
57-
repo,
58-
pull_number
59-
});
60-
61-
const relevantPaths = ['library/', 'doc/src/challenges/'];
62-
const isRelevantPR = files.data.some(file =>
63-
relevantPaths.some(path => file.filename.startsWith(path))
64-
);
65-
66-
if (!isRelevantPR) {
67-
console.log('PR does not touch relevant paths. Exiting workflow.');
68-
return;
69-
}
7048
7149
// Get parsed data
7250
try {
@@ -117,45 +95,6 @@ jobs:
11795
text: `Approvers: ${Array.from(approvers).join(', ')}\nRequired Approvers: ${requiredApprovers.join(', ')}`
11896
};
11997
120-
// Get PR details
121-
const pr = await github.rest.pulls.get({
122-
owner,
123-
repo,
124-
pull_number
125-
});
126-
127-
// Create or update check run
128-
const checkRuns = await github.rest.checks.listForRef({
129-
owner,
130-
repo,
131-
ref: pr.data.head.sha,
132-
check_name: checkName
133-
});
134-
135-
// Reuse the same workflow everytime there's a new review submitted
136-
// instead of creating new workflows. Better efficiency and readability
137-
// as the number of workflows is kept to a minimal number
138-
if (checkRuns.data.total_count > 0) {
139-
await github.rest.checks.update({
140-
owner,
141-
repo,
142-
check_run_id: checkRuns.data.check_runs[0].id,
143-
status: 'completed',
144-
conclusion,
145-
output
146-
});
147-
} else {
148-
await github.rest.checks.create({
149-
owner,
150-
repo,
151-
name: checkName,
152-
head_sha: pr.data.head.sha,
153-
status: 'completed',
154-
conclusion,
155-
output
156-
});
157-
}
158-
15998
if (conclusion === 'failure') {
16099
core.setFailed(`PR needs at least ${requiredApprovals} total approvals and 2 required approvals. Current approvals: ${approvers.size}, Required approvals: ${requiredApprovals}`);
161100
}

0 commit comments

Comments
 (0)