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
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-admins'; | |
# const GROUP_B = 'smart-contract-core'; | |
# const GROUP_C = 'auditors'; | |
# async function getTeamMembers(org, teamSlug) { | |
# const members = []; | |
# let page = 1; | |
# console.log("before while") | |
# while (true) { | |
# console.log(`in while with page ${page}`) | |
# const { data } = await github.rest.teams.listMembersInOrg({ | |
# org, | |
# team_slug: teamSlug, | |
# per_page: 100, | |
# page | |
# }); | |
# console.log("pushing members now") | |
# members.push(...data.map(member => member.login)); | |
# if (data.length < 100) break; | |
# page++; | |
# } | |
# return members; | |
# } | |
# async function run() { | |
# console.log("A") | |
# const groupAMembers = await getTeamMembers(ORG_NAME, GROUP_A); | |
# console.log("B") | |
# const groupBMembers = await getTeamMembers(ORG_NAME, GROUP_B); | |
# console.log("C") | |
# const groupCMembers = await getTeamMembers(ORG_NAME, GROUP_C); | |
# console.log(`groupAMembers.length: ${groupAMembers.length}`) | |
# console.log(`groupBMembers.length: ${groupBMembers.length}`) | |
# console.log(`groupCMembers.length: ${groupCMembers.length}`) | |
# // 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_C}.`); | |
# } | |
# // check overlap between smart-contract-admins and auditors | |
# const overlap2 = groupBMembers.filter(member => groupCMembers.includes(member)); | |
# if (overlap2.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_B} and ${GROUP_C}.`); | |
# } | |
# } | |
# await run(); | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GIT_TOKEN }} | |
- name: Print Group Members | |
env: | |
GH_PAT: ${{ secrets.GIT_TOKEN }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
##### unset the default git token (does not have sufficient rights to get team members) | |
unset GITHUB_TOKEN | |
##### use the Personal Access Token to log into git CLI | |
echo $GH_PAT | gh auth login --with-token | |
##### update the PR title | |
BLA=gh api \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
/orgs/lifinance/teams/auditors/members | |
echo "bla: $BLA" |