Skip to content
Merged
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
48 changes: 31 additions & 17 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ ORG_ROLE_ASSIGNMENTS.forEach((assignment) => {
// @pulumi/github release that includes that fix.
const orgRoleTeamNames = [...new Set(ORG_ROLE_ASSIGNMENTS.map((a) => a.team))];

// Access-only entries that are being renamed, under their old and new names. GitHub redirects
// the old name, so deleting the old resource would remove everyone's access to the repository.
// Pulumi forgets it instead. Deploy this before the rename, and remove the names after it.
const RENAMED_REPOSITORIES = [
'experimental-ext-grouping',
'experimental-ext-triggers-events',
'ext-events',
'progressive-disclosure-wg',
];

// Repositories. An entry with `settings` is created and owned by Pulumi; the
// collaborators resource then depends on it through the name output, so a new
// repository and its access land in the same apply. Entries without `settings`
Expand Down Expand Up @@ -132,23 +142,27 @@ REPOSITORY_ACCESS.forEach((repo) => {
}

const grantedTeams = new Set(repo.teams?.map((t) => t.team));
new github.RepositoryCollaborators(`repo-${repo.repository}`, {
repository: repositoryName,
// Ignore org-role teams, except where repoAccess.ts grants them directly on
// this repository (e.g. lead-maintainers on maintainer-docs) — those grants
// must stay managed by Pulumi.
ignoreTeams: orgRoleTeamNames
.filter((team) => !grantedTeams.has(team))
.map((team) => ({ teamId: teams[team].slug })),
teams: repo.teams?.map((t) => ({
teamId: teams[t.team]?.id,
permission: t.permission,
})),
users: repo.users?.map((u) => ({
username: u.username,
permission: u.permission,
})),
});
new github.RepositoryCollaborators(
`repo-${repo.repository}`,
{
repository: repositoryName,
// Ignore org-role teams, except where repoAccess.ts grants them directly on
// this repository (e.g. lead-maintainers on maintainer-docs) — those grants
// must stay managed by Pulumi.
ignoreTeams: orgRoleTeamNames
.filter((team) => !grantedTeams.has(team))
.map((team) => ({ teamId: teams[team].slug })),
teams: repo.teams?.map((t) => ({
teamId: teams[t.team]?.id,
permission: t.permission,
})),
users: repo.users?.map((u) => ({
username: u.username,
permission: u.permission,
})),
},
{ retainOnDelete: RENAMED_REPOSITORIES.includes(repo.repository) }
);
});

export { teams as githubTeams, repositories as githubRepositories };
Loading