Skip to content
Open
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Make sure to add the relevant inputs:
- `repo-token` is your `${{ secrets.GITHUB_TOKEN }}`. You may encounter an error where this token does not have the necessary permissions to access an organization or teams. At EquityBee, we use PATs (Personal Access Token) instead. Create a [personal access token](https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token) with the repo or public_repo scopes enabled, and add the token as an [encrypted secret](https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository) for the repository or organization
- `organization-name` is the name/slug of your Github organization (it comes right after `https://github.com/`)
- `ignore-labels` is an optional, comma-separated list of labels to ignore
- `only-labels` is an optional, comma-separated list of the only labels to include

## Internal use

Expand Down
5 changes: 4 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions src/__tests__/octokit-queries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,30 @@ describe('getTeamSlugsForAuthor', () => {
expect(teamSlugs).toStrictEqual(['team-active']);
});
});

describe('with only teams', () => {
beforeEach(async () => {
teamSlugs = await getTeamSlugsForAuthor(octokit, 'ORG', 'USER', [], ['team-active']);
});

it('should return filtered teams', () => {
expect(teamSlugs).toStrictEqual(['team-active']);
});
});

describe('with only/ignored teams', () => {
beforeEach(async () => {
teamSlugs = await getTeamSlugsForAuthor(
octokit,
'ORG',
'USER',
['team-active'],
['team-active'],
);
});

it('applies ignored teams', () => {
expect(teamSlugs).toStrictEqual([]);
});
});
});
5 changes: 5 additions & 0 deletions src/octokit-queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export const getTeamSlugsForAuthor = async (
org: string,
username: string,
ignoreSlugs: string[] = [],
onlySlugs: string[] = [],
): Promise<string[]> => {
const { data: allTeams } = await octokit.rest.teams.list({
org,
Expand All @@ -18,6 +19,10 @@ export const getTeamSlugsForAuthor = async (
continue;
}

if (onlySlugs.length > 0 && !onlySlugs.includes(slug)) {
continue;
}

try {
const { data: membership } = await octokit.rest.teams.getMembershipForUserInOrg({
org,
Expand Down