Skip to content

Commit

Permalink
fix: ignore archived repositories (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoehnelt committed May 7, 2020
1 parent 77cff60 commit e555e29
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 6 deletions.
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

0 comments on commit e555e29

Please sign in to comment.