Construct orgClient inside github-script to fix module resolution

@actions/github is only resolvable from inside the github-script bundle,
not from main.js. Build the PAT-authed Octokit client in action.yml and
pass it into main as orgClient. Switch the team-membership check to use
orgClient.rest.teams.getMembershipForUserInOrg instead of a raw request
with header override.
This commit is contained in:
Den Delimarsky 2026-03-11 22:48:40 +00:00
commit 5d105acf64
No known key found for this signature in database

View file

@ -99,5 +99,11 @@ runs:
with:
github-token: ${{ inputs.bot-token }}
script: |
// Construct a second Octokit client authed with the PAT for
// org team-membership checks. This has to happen here, not in
// main.js, because @actions/github is only resolvable from
// inside the github-script bundle.
const { getOctokit } = require('@actions/github');
const orgClient = getOctokit(process.env.ORG_TOKEN);
const main = require(process.env.GITHUB_ACTION_PATH + '/main.js');
await main({ github, context, core });
await main({ github, context, core, orgClient });