From a269d8134240d609b9216444d25cdaaebca617d0 Mon Sep 17 00:00:00 2001 From: Hamothy <58985301+sgoudham@users.noreply.github.com> Date: Sat, 21 Oct 2023 19:27:32 +0100 Subject: [PATCH] ci: sync only the `current-maintainers` (#275) This commit ensures that the syncMaintainers GitHub action does not send team invites to all collaborators but only the current maintainers. --- src/generate/syncMaintainers.ts | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/generate/syncMaintainers.ts b/src/generate/syncMaintainers.ts index f063a90b..c6f7afeb 100755 --- a/src/generate/syncMaintainers.ts +++ b/src/generate/syncMaintainers.ts @@ -1,6 +1,6 @@ #!/usr/bin/env -S deno run --allow-read --allow-net --allow-env import { Ajv, assert, Octokit, parseYaml, path, schema } from "./deps.ts"; -import { UserstylesSchema } from "./types.d.ts"; +import { Userstyle, UserstylesSchema } from "./types.d.ts"; const octokit = new Octokit({ auth: Deno.env.get("GITHUB_TOKEN") }); const team = { org: "catppuccin", team_slug: "userstyles-maintainers" }; @@ -19,13 +19,20 @@ if (!validate(userstylesData)) { Deno.exit(1); } -// lowercase usernames of all maintainers in the file -const maintainers = userstylesData.collaborators?.map((c) => { - const username = c.url.split("github.com/")?.pop(); - // check that they follow github.com/username pattern - assert.assertExists(username); - return username.toLowerCase(); -}); +// lowercase usernames of all the "current-maintainers" in the file +const maintainers = [ + ...new Set( + Object.values(userstylesData.userstyles).flatMap((style: Userstyle) => + style.readme["current-maintainers"].map((m) => { + const username = m.url.split("github.com/")?.pop(); + // check that they follow github.com/username pattern + assert.assertExists(username); + return username.toLowerCase(); + } + ) + ) + ) +]; // lowercase usernames of all maintainers in the current GH team const teamMembers = await octokit.teams.listMembersInOrg({ @@ -58,4 +65,4 @@ const syncMaintainers = async () => { } }; -await syncMaintainers(); +await syncMaintainers(); \ No newline at end of file