diff --git a/src/config/repoAccess.ts b/src/config/repoAccess.ts index 5821e93..038dea2 100644 --- a/src/config/repoAccess.ts +++ b/src/config/repoAccess.ts @@ -40,10 +40,11 @@ export interface RepositoryAccess { * name-already-exists error. Adopt it with `pulumi import` first. The * `repository` key of a managed entry is also the Pulumi resource name, so * renaming it in place archives the old repository and creates a new one. - * To rename, do three things in order: rename the repository on GitHub, - * rename the resources in state with `pulumi state rename` - * (`repository-` to `repository-`, and `repo-` to - * `repo-`), then change the key. + * To rename an access-only entry after its repository was renamed on GitHub, + * deploy `retainOnDelete: true` on its collaborators resource, then change the + * key, then drop the option. Otherwise deleting the old resource follows + * GitHub's redirect and removes the repository's access. These steps + * don't cover managed entries. */ settings?: RepositorySettings; teams?: Array<{ diff --git a/src/github.ts b/src/github.ts index c290fc0..a744f35 100644 --- a/src/github.ts +++ b/src/github.ts @@ -98,16 +98,6 @@ 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` @@ -142,27 +132,23 @@ 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, - })), - }, - { retainOnDelete: RENAMED_REPOSITORIES.includes(repo.repository) } - ); + 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, + })), + }); }); export { teams as githubTeams, repositories as githubRepositories };