mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-07-09 17:28:45 +00:00
fix(coding-agent): use PAT directly for issue analysis auth
This commit is contained in:
parent
abe9c9d9f1
commit
d1e72d0585
1 changed files with 32 additions and 9 deletions
41
.github/workflows/issue-analysis.yml
vendored
41
.github/workflows/issue-analysis.yml
vendored
|
|
@ -63,13 +63,33 @@ jobs:
|
|||
}
|
||||
|
||||
try {
|
||||
const { getOctokit } = require('@actions/github');
|
||||
const orgGithub = getOctokit(process.env.ORG_READ_TOKEN);
|
||||
const { data: membership } = await orgGithub.rest.teams.getMembershipForUserInOrg({
|
||||
org: 'earendil-works',
|
||||
team_slug: 'staff',
|
||||
username,
|
||||
});
|
||||
const response = await fetch(
|
||||
`https://api.github.com/orgs/earendil-works/teams/staff/memberships/${encodeURIComponent(username)}`,
|
||||
{
|
||||
headers: {
|
||||
Accept: 'application/vnd.github+json',
|
||||
Authorization: `Bearer ${process.env.ORG_READ_TOKEN}`,
|
||||
'X-GitHub-Api-Version': '2022-11-28',
|
||||
},
|
||||
},
|
||||
);
|
||||
|
||||
if (response.status === 404) {
|
||||
await removeTriggerLabel();
|
||||
core.setFailed(`@${username} is not an active earendil-works/staff member.`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!response.ok) {
|
||||
const body = await response.text();
|
||||
await removeTriggerLabel();
|
||||
core.setFailed(
|
||||
`Could not verify earendil-works/staff membership for @${username}: HTTP ${response.status} ${body}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const membership = await response.json();
|
||||
if (membership.state !== 'active') {
|
||||
await removeTriggerLabel();
|
||||
core.setFailed(`@${username} is not an active earendil-works/staff member.`);
|
||||
|
|
@ -78,8 +98,11 @@ jobs:
|
|||
console.log(`earendil-works/staff membership for @${username}: ${membership.state}`);
|
||||
} catch (error) {
|
||||
await removeTriggerLabel();
|
||||
const status = typeof error === 'object' && error !== null && 'status' in error ? error.status : 'unknown';
|
||||
core.setFailed(`Could not verify earendil-works/staff membership for @${username}: ${status}`);
|
||||
core.setFailed(
|
||||
`Could not verify earendil-works/staff membership for @${username}: ${
|
||||
error instanceof Error ? error.message : String(error)
|
||||
}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue