Skip to content

Commit 60dfc93

Browse files
authored
Clean up after two repository renames (#287)
1 parent b51fc35 commit 60dfc93

2 files changed

Lines changed: 22 additions & 35 deletions

File tree

‎src/config/repoAccess.ts‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,11 @@ export interface RepositoryAccess {
4040
* name-already-exists error. Adopt it with `pulumi import` first. The
4141
* `repository` key of a managed entry is also the Pulumi resource name, so
4242
* renaming it in place archives the old repository and creates a new one.
43-
* To rename, do three things in order: rename the repository on GitHub,
44-
* rename the resources in state with `pulumi state rename`
45-
* (`repository-<old>` to `repository-<new>`, and `repo-<old>` to
46-
* `repo-<new>`), then change the key.
43+
* To rename an access-only entry after its repository was renamed on GitHub,
44+
* deploy `retainOnDelete: true` on its collaborators resource, then change the
45+
* key, then drop the option. Otherwise deleting the old resource follows
46+
* GitHub's redirect and removes the repository's access. These steps
47+
* don't cover managed entries.
4748
*/
4849
settings?: RepositorySettings;
4950
teams?: Array<{

‎src/github.ts‎

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -98,16 +98,6 @@ ORG_ROLE_ASSIGNMENTS.forEach((assignment) => {
9898
// @pulumi/github release that includes that fix.
9999
const orgRoleTeamNames = [...new Set(ORG_ROLE_ASSIGNMENTS.map((a) => a.team))];
100100

101-
// Access-only entries that are being renamed, under their old and new names. GitHub redirects
102-
// the old name, so deleting the old resource would remove everyone's access to the repository.
103-
// Pulumi forgets it instead. Deploy this before the rename, and remove the names after it.
104-
const RENAMED_REPOSITORIES = [
105-
'experimental-ext-grouping',
106-
'experimental-ext-triggers-events',
107-
'ext-events',
108-
'progressive-disclosure-wg',
109-
];
110-
111101
// Repositories. An entry with `settings` is created and owned by Pulumi; the
112102
// collaborators resource then depends on it through the name output, so a new
113103
// repository and its access land in the same apply. Entries without `settings`
@@ -142,27 +132,23 @@ REPOSITORY_ACCESS.forEach((repo) => {
142132
}
143133

144134
const grantedTeams = new Set(repo.teams?.map((t) => t.team));
145-
new github.RepositoryCollaborators(
146-
`repo-${repo.repository}`,
147-
{
148-
repository: repositoryName,
149-
// Ignore org-role teams, except where repoAccess.ts grants them directly on
150-
// this repository (e.g. lead-maintainers on maintainer-docs) — those grants
151-
// must stay managed by Pulumi.
152-
ignoreTeams: orgRoleTeamNames
153-
.filter((team) => !grantedTeams.has(team))
154-
.map((team) => ({ teamId: teams[team].slug })),
155-
teams: repo.teams?.map((t) => ({
156-
teamId: teams[t.team]?.id,
157-
permission: t.permission,
158-
})),
159-
users: repo.users?.map((u) => ({
160-
username: u.username,
161-
permission: u.permission,
162-
})),
163-
},
164-
{ retainOnDelete: RENAMED_REPOSITORIES.includes(repo.repository) }
165-
);
135+
new github.RepositoryCollaborators(`repo-${repo.repository}`, {
136+
repository: repositoryName,
137+
// Ignore org-role teams, except where repoAccess.ts grants them directly on
138+
// this repository (e.g. lead-maintainers on maintainer-docs) — those grants
139+
// must stay managed by Pulumi.
140+
ignoreTeams: orgRoleTeamNames
141+
.filter((team) => !grantedTeams.has(team))
142+
.map((team) => ({ teamId: teams[team].slug })),
143+
teams: repo.teams?.map((t) => ({
144+
teamId: teams[t.team]?.id,
145+
permission: t.permission,
146+
})),
147+
users: repo.users?.map((u) => ({
148+
username: u.username,
149+
permission: u.permission,
150+
})),
151+
});
166152
});
167153

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

0 commit comments

Comments
 (0)