Skip to main content
Glama

github_cicd_setup

Automate deployment by configuring GitHub CI/CD pipelines with deploy keys and workflows, specifying repository URLs and server deployment paths. Streamline VPS setup and management.

Instructions

Setup GitHub CI/CD with deploy keys and workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
deployPathYesDeployment path on server
repoUrlYesGitHub repository URL

Implementation Reference

  • Core handler function `setupCICD` in GitHubCICD class that orchestrates the entire GitHub CI/CD setup: generates deploy key, sets up deployment directory and script, generates action secret, and creates workflow YAML.
    async setupCICD(config: GitHubCICDConfig): Promise<GitHubCICDResult> { try { logger.info('Setting up GitHub CI/CD', { repoUrl: config.repoUrl, deployPath: config.deployPath, }); // Generate deploy key const deployKey = await this.generateDeployKey(); if (!deployKey) { return { success: false, message: 'Failed to generate deploy key', }; } // Setup deployment directory const setupResult = await this.setupDeploymentDirectory(config.deployPath); if (!setupResult.success) { return setupResult; } // Generate action secret const actionSecret = await this.generateActionSecret(); if (!actionSecret) { return { success: false, message: 'Failed to generate action secret', }; } // Create workflow file const workflowFile = this.generateWorkflowFile(config); return { success: true, message: 'GitHub CI/CD setup completed successfully', deployKey, actionSecret, workflowFile, }; } catch (error) { logger.error('GitHub CI/CD setup failed', { error, config }); return { success: false, message: `GitHub CI/CD setup failed: ${error instanceof Error ? error.message : 'Unknown error'}`, }; } }
  • MCP server handler `handleGitHubCICDSetup` that validates input with Zod schema and delegates to GitHubCICD.setupCICD, formats response.
    private async handleGitHubCICDSetup( args: unknown ): Promise<{ content: Array<{ type: 'text'; text: string }> }> { if (!this.githubCICD) { throw new Error('SSH connection not established. Please connect first.'); } const config = GitHubConfigSchema.parse(args); const result = await this.githubCICD.setupCICD(config); return { content: [ { type: 'text', text: result.success ? `GitHub CI/CD setup completed. Deploy key and workflow generated.` : `GitHub CI/CD setup failed: ${result.message}`, }, ], }; }
  • Tool registration in ListToolsRequestHandler, including name, description, and input schema.
    name: 'github_cicd_setup', description: 'Setup GitHub CI/CD with deploy keys and workflow', inputSchema: { type: 'object', properties: { repoUrl: { type: 'string', description: 'GitHub repository URL' }, deployPath: { type: 'string', description: 'Deployment path on server' }, }, required: ['repoUrl', 'deployPath'], }, },
  • Zod schema for validating github_cicd_setup tool input parameters.
    const GitHubConfigSchema = z.object({ repoUrl: z.string().describe('GitHub repository URL'), deployPath: z.string().describe('Deployment path on the server'), });
  • Helper method to generate SSH deploy key pair on the server, read public/private keys and fingerprint.
    private async generateDeployKey(): Promise<DeployKey | null> { try { // Generate SSH key pair const keyPath = '/root/.ssh/deploy_key'; const generateResult = await this.sshService.executeCommand( `ssh-keygen -t ed25519 -C "deploy-key-$(date +%s)" -f ${keyPath} -N ""` ); if (!generateResult.success) { logger.error('Failed to generate deploy key', { error: generateResult.stderr }); return null; } // Read public key const publicKeyResult = await this.sshService.executeCommand(`cat ${keyPath}.pub`); if (!publicKeyResult.success) { logger.error('Failed to read public key', { error: publicKeyResult.stderr }); return null; } // Read private key const privateKeyResult = await this.sshService.executeCommand(`cat ${keyPath}`); if (!privateKeyResult.success) { logger.error('Failed to read private key', { error: privateKeyResult.stderr }); return null; } // Get fingerprint const fingerprintResult = await this.sshService.executeCommand( `ssh-keygen -lf ${keyPath}.pub` ); const fingerprint = fingerprintResult.success ? fingerprintResult.stdout.split(' ')[1] || 'Unknown' : 'Unknown'; return { publicKey: publicKeyResult.stdout.trim(), privateKey: privateKeyResult.stdout.trim(), fingerprint, }; } catch (error) { logger.error('Deploy key generation failed', { error }); return null; } }

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/oxy-Op/DevPilot'

If you have feedback or need assistance with the MCP directory API, please join our Discord server