Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions actions/setup/js/check_membership.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async function main() {
return;
}

if (!requiredPermissions || requiredPermissions.length === 0) {
if (requiredPermissions.length === 0) {
core.warning("❌ Configuration error: Required permissions not specified. Contact repository administrator.");
core.setOutput("is_team_member", "false");
core.setOutput("result", "config_error");
Expand All @@ -60,7 +60,7 @@ async function main() {
// User doesn't have required permissions (or the permission check failed with an error).
// Always attempt the bot allowlist fallback before giving up, so that GitHub Apps whose
// actor is not a recognized GitHub user (e.g. "Copilot") are not silently denied.
if (allowedBots && allowedBots.length > 0) {
if (allowedBots.length > 0) {
core.info(`Checking if actor '${actor}' is in allowed bots list: ${allowedBots.join(", ")}`);

if (isAllowedBot(actor, allowedBots)) {
Expand Down
30 changes: 30 additions & 0 deletions actions/setup/js/check_membership.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -441,5 +441,35 @@ describe("check_membership.cjs", () => {
expect(mockCore.setOutput).toHaveBeenCalledWith("is_team_member", "true");
expect(mockCore.setOutput).toHaveBeenCalledWith("result", "authorized_bot");
});

it("should skip bot check when GH_AW_ALLOWED_BOTS is empty string", async () => {
process.env.GH_AW_ALLOWED_BOTS = "";

mockGithub.rest.repos.getCollaboratorPermissionLevel.mockResolvedValueOnce({
data: { permission: "none" },
});

await runScript();

// Only 1 API call (the permission check) — no bot status check
expect(mockGithub.rest.repos.getCollaboratorPermissionLevel).toHaveBeenCalledTimes(1);
expect(mockCore.setOutput).toHaveBeenCalledWith("is_team_member", "false");
expect(mockCore.setOutput).toHaveBeenCalledWith("result", "insufficient_permissions");
});

it("should skip bot check when GH_AW_ALLOWED_BOTS is not set", async () => {
delete process.env.GH_AW_ALLOWED_BOTS;

mockGithub.rest.repos.getCollaboratorPermissionLevel.mockResolvedValueOnce({
data: { permission: "none" },
});

await runScript();

// Only 1 API call (the permission check) — no bot status check
expect(mockGithub.rest.repos.getCollaboratorPermissionLevel).toHaveBeenCalledTimes(1);
expect(mockCore.setOutput).toHaveBeenCalledWith("is_team_member", "false");
expect(mockCore.setOutput).toHaveBeenCalledWith("result", "insufficient_permissions");
});
});
});
Loading