Collaborator
Source:
src/GitHub/Collaborator.ts
A GitHub repository collaborator.
Collaborator grants a user direct access to a repository. For
organization-owned repositories, prefer GitHub.TeamAccess to grant
access through teams instead of individual users.
Collaborators default to retain on removal — destroying the stack does
NOT remove the collaborator, preventing accidental lockout. Opt in to
actual removal by wrapping the resource in destroy() from
alchemy/RemovalPolicy.
Authentication is resolved via the GitHubCredentials service supplied by
GitHub.providers() (env, stored PAT, gh CLI, or OAuth). The token needs
repo scope (and admin:repo for removal when opted in via destroy()).
Adding a Collaborator
Section titled “Adding a Collaborator”Grant Push Access
yield* GitHub.Collaborator("collaborator", { owner: "my-org", repository: "my-repo", username: "contributor", permission: "push",})Grant Admin Access
yield* GitHub.Collaborator("admin", { owner: "my-org", repository: "my-repo", username: "team-lead", permission: "admin",})Grant Read-Only Access
yield* GitHub.Collaborator("readonly", { owner: "my-org", repository: "my-repo", username: "auditor", permission: "pull",})Removing a Collaborator
Section titled “Removing a Collaborator”import { destroy } from "alchemy/RemovalPolicy"
yield* GitHub.Collaborator("temp", { owner: "my-org", repository: "my-repo", username: "contractor", permission: "push",}).pipe(destroy())