Skip to content

Commit ad27f54

Browse files
committed
add github actions for jump and anza approval
1 parent 1ebbb2d commit ad27f54

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Require 1 Jump + 1 Anza approval
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, synchronize, ready_for_review]
6+
pull_request_review:
7+
types: [submitted, dismissed, edited]
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Verify approvals
14+
uses: actions/github-script@v7
15+
with:
16+
script: |
17+
const {github, context, core} = require('@actions/github')
18+
19+
20+
const jumpApprovers = ['jacobcreech', 'topointon-jump','0x0ece']
21+
const anzaApprovers = ['benhawkins18', 't-nelson','sakridge']
22+
//TODO: remove benhawkins18 and JacobCreech from the list of approvers and get final list from Jump and Anza
23+
24+
25+
// pull all reviews on this PR
26+
const prNum = context.payload.pull_request.number
27+
const {data: reviews} = await github.rest.pulls.listReviews({
28+
owner: context.repo.owner,
29+
repo: context.repo.repo,
30+
pull_number: prNum,
31+
per_page: 100
32+
})
33+
34+
// keep last state per reviewer
35+
const latest = {}
36+
reviews.forEach(r => latest[r.user.login] = r.state)
37+
const approved = Object.entries(latest)
38+
.filter(([,s]) => s === 'APPROVED')
39+
.map(([u]) => u)
40+
41+
const hasJump = jumpApprovers.some(u => approved.includes(u))
42+
const hasAnza = anzaApprovers.some(u => approved.includes(u))
43+
44+
core.summary.addHeading('Jump + Anza approval check')
45+
.addRaw(`Jump: **${hasJump ? '✔︎' : '✘'}** • ` +
46+
`Anza: **${hasAnza ? '✔︎' : '✘'}**`).write()
47+
48+
if (!hasJump || !hasAnza) {
49+
core.setFailed('Need at least one Jump and one Anza approval')
50+
}

0 commit comments

Comments
 (0)