Skip to content

Test: add github action for jump and anza approval #7

Test: add github action for jump and anza approval

Test: add github action for jump and anza approval #7

name: Require 1 Jump + 1 Anza approval

Check failure on line 1 in .github/workflows/require-jump-anza.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/require-jump-anza.yml

Invalid workflow file

Invalid `steps` value - steps should be list of `uses` or `run` items
on:
pull_request:
types: [opened, reopened, synchronize, ready_for_review]
pull_request_review:
types: [submitted, dismissed, edited]
jobs:
check:
runs-on: ubuntu-latest
steps:
name: Verify Jump + Anza approvals
uses: actions/github-script@v7
with:
script: |
// ---- hard-coded rosters ----
const jumpApprovers = ['jacobcreech', 'topointon-jump', '0x0ece']
const anzaApprovers = ['benhawkins18', 'tigarcia', 't-nelson', 'sakridge']
// -----------------------------
// pull every review on this PR
const prNum = context.payload.pull_request.number
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: prNum,
per_page: 100
})
/* Build the “effective” state for each reviewer:
- If the latest review is REQUEST_CHANGES → disqualify
- Else if they ever APPROVED (and never requested changes later) → qualifies
- COMMENTED doesn’t override a prior APPROVED
*/
const states = {} // username → {hasApproved, blocked}
reviews.forEach(r => {
const u = r.user.login
states[u] = states[u] || {hasApproved: false, blocked: false}
if (r.state === 'REQUEST_CHANGES') states[u].blocked = true
if (r.state === 'APPROVED') states[u].hasApproved = true
})
const approved = Object.entries(states)
.filter(([,s]) => s.hasApproved && !s.blocked)
.map(([u]) => u)
const hasJump = jumpApprovers.some(u => approved.includes(u))
const hasAnza = anzaApprovers.some(u => approved.includes(u))
core.summary
.addHeading('Jump + Anza approval check')
.addRaw(`Jump: **${hasJump ? '✔' : '✘'}** • ` +
`Anza: **${hasAnza ? '✔' : '✘'}**`)
.write()
if (!hasJump || !hasAnza) {
core.setFailed('Need at least one Jump and one Anza approval')
}