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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ repositories:
<gh_username>: read | triage | write | maintain | admin
# Public vs Private repository, no value is assumed to mean public
visibility: public | private
# Should the repo be archived, defaults to false
# Will unarchive the repo if changed from true to false
archived: <boolean>
```

#### Generating your initial configuration
Expand Down
1 change: 1 addition & 0 deletions src/permissions/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ async function main(spinner: ora.Ora) {
}})`;
const repoConfig: RepositoryConfig = {
name: repo.name,
archived: repo.archived,
};
const [currentTeams, currentCollaborators] = await Promise.all([
octokit.paginate('GET /repos/{owner}/{repo}/teams', {
Expand Down
20 changes: 20 additions & 0 deletions src/permissions/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ const validateConfigFast = async (config: PermissionsConfig) => {
has_wiki: Joi.boolean(),
}).optional(),
visibility: Joi.string().only('public', 'private').optional(),
archived: Joi.boolean().optional(),
})
.required(),
});
Expand Down Expand Up @@ -989,6 +990,25 @@ async function checkRepository(
}
}

const shouldBeArchived = repo.archived || false;
if (octoRepo.archived !== shouldBeArchived) {
if (shouldBeArchived) {
builder.addContext(`:file_cabinet: Archiving \`${octoRepo.name}\``);
console.info(chalk.yellow('Archiving'), chalk.cyan(octoRepo.name));
} else {
builder.addContext(`:file_cabinet: Unarchiving \`${octoRepo.name}\``);
console.info(chalk.yellow('Unarchiving'), chalk.cyan(octoRepo.name));
}
if (!IS_DRY_RUN) {
const octokit = await getOctokit(config.organization);
await octokit.repos.update({
owner: config.organization,
repo: octoRepo.name,
archived: shouldBeArchived,
});
}
}

for (const supposedCollaboratorName of Object.keys(repo.external_collaborators || {})) {
// Supposed collaborator is not currently in the repo and should be added
if (
Expand Down
1 change: 1 addition & 0 deletions src/permissions/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface RepositoryConfig {
external_collaborators?: Record<string, SheriffAccessLevel>;
settings?: Partial<RepoSettings>;
visibility?: 'public' | 'private';
archived?: boolean;
}

export interface RepoSettings {
Expand Down