Skip to main content
Version: 1.0.0

Deploying GitHub Repos Programmatically

Overview

This guide will show you how to deploy a GitHub repository programmatically using the Zeet GraphQL API. You can use this guide to deploy any GitHub repository (public or private).

Prerequisites

Before making API requests, make sure that you have the Zeet GraphQL API ready and working. You can use the Getting Started guide for reference. Before deploying, you'll want to connect a Kubernetes cluster to Zeet. You will need your Team ID, and your Zeet Cluster ID. You can grab those here:

# using v0 API endpoint:
# https://anchor.zeet.co/graphql
query {
currentUser {
teams {
team {
name
user {
id # This is $YOUR_TEAM_ID
clusters {
id # This is $YOUR_CLUSTER_ID
name
}
}
}
}
}
}

Creating a New Project

In order to deploy a GitHub repository using Zeet, you need to create a project. For this example, we'll use the api v0 endpoint. Ensure you are making requests to the correct GraphQL endpoint!

This is a single request that will create a new project, and deploy it to your cluster:

mutation {
createResourceAlpha(
input: {
userID: $YOUR_TEAM_ID
name: "github-project"
projectName: "api-docs" # Group
environmentName: "example" # Sub-group
blueprintID: "b1d61b3f-7950-4cba-9bc9-198f31c46ce8" # Official Container Image Blueprint
source: {
git: {
repository: "https://github.com/zeet-demo/node-express-demo.git"
# integration: { githubInstallationID: $YOUR_GITHUB_INSTALLATION_ID } # When using a private repo
}
}
build: {
build: {
buildType: NODE
buildCommand: "npm --production=false install"
nodejsVersion: "18"
runCommand: "npm start"
workingDirectory: "./"
}
}
kubernetes: {
deployTarget: {
deployTarget: KUBERNETES
clusterID: $YOUR_CLUSTER_ID
}
app: {
deployService: true
volumes: []
envs: []
ports: [{ port: "3000", protocol: tcp, public: true, https: true }]
resources: { cpu: 1, memory: 1, spot: false }
}
}
enabled: true
}
) {
id
}
}

If successful, you'll get a response like:

{
"data": {
"createResourceAlpha": {
"id": "d32a73b4-5e1c-4478-947f-6f65b6852bc6" // This is $YOUR_PROJECT_ID
}
},
"extensions": {
"requestId": "9f212c26-feaf-418b-914e-079b5f721c55"
}
}

You can check the status of your deployment by querying the project:

query {
currentUser {
repo(id: $YOUR_PROJECT_ID) {
productionDeployment {
status
endpoints
}
}
}
}

Congrats! You've deployed a GitHub repository using the Zeet GraphQL API.