workflows/bot: avoid access teams endpoints in Test workflow

We have no chance of getting a token that can request the team endpoints
in the pull_request context. This makes sense, because non-members of
the org are also not allowed to view the teams' memberships.

Thus, just fake an empty team - that's fine for the Test workflow.
This commit is contained in:
Wolfgang Walther
2025-11-01 17:37:03 +01:00
parent 77a3b006cd
commit 421974863f

View File

@@ -6,13 +6,21 @@ async function runChecklist({ github, context, pull_request, maintainers }) {
const pull_number = pull_request.number const pull_number = pull_request.number
if (!committers) { if (!committers) {
committers = github if (context.eventName === 'pull_request') {
.paginate(github.rest.teams.listMembersInOrg, { // We have no chance of getting a token in the pull_request context with the right
org: context.repo.owner, // permissions to access the members endpoint below. Thus, we're pretending to have
team_slug: 'nixpkgs-committers', // no committers. This is OK; because this is only for the Test workflow, not for
per_page: 100, // real use.
}) committers = new Set()
.then((members) => new Set(members.map(({ id }) => id))) } else {
committers = github
.paginate(github.rest.teams.listMembersInOrg, {
org: context.repo.owner,
team_slug: 'nixpkgs-committers',
per_page: 100,
})
.then((members) => new Set(members.map(({ id }) => id)))
}
} }
const files = await github.paginate(github.rest.pulls.listFiles, { const files = await github.paginate(github.rest.pulls.listFiles, {