Unverified Commit 42197486 authored by Wolfgang Walther's avatar Wolfgang Walther
Browse files

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.
parent 77a3b006
Loading
Loading
Loading
Loading
+15 −7
Original line number Diff line number Diff line
@@ -6,6 +6,13 @@ async function runChecklist({ github, context, pull_request, maintainers }) {
  const pull_number = pull_request.number

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

  const files = await github.paginate(github.rest.pulls.listFiles, {
    ...context.repo,