GitHub
GitHub is a web-based version control and collaboration platform that provides Git repository hosting, issue tracking, project management, and CI/CD workflows. Alchemy provides resources to manage GitHub repositories, environments, secrets, and comments programmatically.
Official GitHub Documentation | GitHub API Reference
Resources
Section titled “Resources”- Comment - Create and manage comments on issues and pull requests
- RepositoryEnvironment - Create and manage deployment environments with protection rules
- RepositoryWebhook - Create and manage repository webhooks for event notifications
- Secret - Create and manage GitHub Actions and Dependabot secrets
Example Usage
Section titled “Example Usage”import { Comment, RepositoryEnvironment, RepositoryWebhook, GitHubSecret } from "alchemy/github";
// Create a repository environmentconst prodEnv = await RepositoryEnvironment("production", { owner: "my-org", repository: "my-repo", name: "production", waitTimer: 10, preventSelfReview: true, reviewers: { teams: ["platform-team"], users: ["security-admin"], }, deploymentBranchPolicy: { protectedBranches: true, customBranchPolicies: false, },});
// Create a webhook for CI/CD notificationsconst webhook = await RepositoryWebhook("ci-webhook", { owner: "my-org", repository: "my-repo", url: "https://ci.example.com/webhook", secret: alchemy.secret("GITHUB_WEBHOOK_SECRET"), events: ["push", "pull_request", "release"],});
// Create a secret for the environmentconst secret = await GitHubSecret("deploy-key", { owner: "my-org", repository: "my-repo", name: "DEPLOY_KEY", value: alchemy.secret(process.env.DEPLOY_KEY), environment: "production",});
// Add a deployment status comment to a PRconst deploymentComment = await Comment("deployment-status", { owner: "my-org", repository: "my-repo", issueNumber: 123, body: "✅ Successfully deployed to production environment!",});