-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
69 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Protect Auditors Group | ||
|
||
on: | ||
push: | ||
|
||
jobs: | ||
check_membership: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Check Group Membership Overlap | ||
uses: actions/github-script@v7 | ||
with: | ||
script: | | ||
const ORG_NAME = 'lifinance'; | ||
const GROUP_A = 'smart-contract-core'; | ||
const GROUP_B = 'smart-contract-admins'; | ||
const GROUP_C = 'auditors'; | ||
async function getTeamMembers(org, teamSlug) { | ||
const members = []; | ||
let page = 1; | ||
while (true) { | ||
const { data } = await github.rest.teams.listMembersInOrg({ | ||
org, | ||
team_slug: teamSlug, | ||
per_page: 100, | ||
page | ||
}); | ||
members.push(...data.map(member => member.login)); | ||
if (data.length < 100) break; | ||
page++; | ||
} | ||
return members; | ||
} | ||
async function run() { | ||
const groupAMembers = await getTeamMembers(ORG_NAME, GROUP_A); | ||
const groupBMembers = await getTeamMembers(ORG_NAME, GROUP_B); | ||
const groupCMembers = await getTeamMembers(ORG_NAME, GROUP_C); | ||
// check overlap between smart-contract-core and auditors | ||
const overlap = groupAMembers.filter(member => groupCMembers.includes(member)); | ||
if (overlap.length > 0) { | ||
core.setFailed(`ERROR: The following members are in both ${GROUP_A} and ${GROUP_C}: ${overlap.join(', ')}`); | ||
} else { | ||
core.info(`No overlap found between ${GROUP_A} and ${GROUP_B}.`); | ||
} | ||
// check overlap between smart-contract-admins and auditors | ||
const overlap = groupBMembers.filter(member => groupCMembers.includes(member)); | ||
if (overlap.length > 0) { | ||
core.setFailed(`ERROR: The following members are in both ${GROUP_B} and ${GROUP_C}: ${overlap.join(', ')}`); | ||
} else { | ||
core.info(`No overlap found between ${GROUP_A} and ${GROUP_B}.`); | ||
} | ||
} | ||
await run(); | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
File renamed without changes.