Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ignore archived repositories #18

Merged
merged 2 commits into from
May 7, 2020
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A Github Action that can sync secrets from one repository to many others. This a

### `repositories`

**Required** New line deliminated regex expressions to select repositories. Repositires are limited to those in whcich the token user is an owner or collaborator. Set `repositories_list_regex` to `False` to use a hardcoded list of repositories.
**Required** New line deliminated regex expressions to select repositories. Repositires are limited to those in whcich the token user is an owner or collaborator. Set `repositories_list_regex` to `False` to use a hardcoded list of repositories. Archived repositories will be ignored.

### `repositories_list_regex`

Expand Down
8 changes: 6 additions & 2 deletions __tests__/github.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,15 @@ afterAll(() => {
});

describe("listing repos from github", () => {
const pageSize = 2;
const pageSize = 3;
beforeEach(() => {
nock("https://api.github.com")
.get(/\/user\/repos?.*page=1.*/)
.reply(200, [fixture[0].response, fixture[0].response]);
.reply(200, [
fixture[0].response,
fixture[0].response,
{ archived: true, full_name: "foo/bar" }
]);

nock("https://api.github.com")
.get(/\/user\/repos?.*page=2.*/)
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
New line deliminated regex expressions to select repositories. Repositires
are limited to those in which the token user is an owner or collaborator.
Set `REPOSITORIES_LIST_REGEX` to `False` to use a hardcoded list of
repositories.
repositories. Archived repositories will be ignored.
required: true
repositories_list_regex:
default: "true"
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7577,7 +7577,7 @@ function listAllReposForAuthenticatedUser({ octokit, affiliation, pageSize }) {
break;
}
}
return repos;
return repos.filter(r => !r.archived);
});
}
exports.listAllReposForAuthenticatedUser = listAllReposForAuthenticatedUser;
Expand Down
3 changes: 2 additions & 1 deletion src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { retry } from "@octokit/plugin-retry";

export interface Repository {
full_name: string;
archived?: boolean;
}

export interface PublicKey {
Expand Down Expand Up @@ -124,7 +125,7 @@ export async function listAllReposForAuthenticatedUser({
break;
}
}
return repos;
return repos.filter(r => !r.archived);
}

export function filterReposByPatterns(
Expand Down