Skip to Content
PlatformDeploy from Git

Deploy from Git

Deploy from Git connects a StackMachine app to a GitHub repository so source control becomes the deployment control plane. Choose the app, repository, and branch once; then keep releases tied to reviewed commits instead of manual uploads.

Features

Branch-based deploys

Connect a repository installation to an app and choose the branch StackMachine should build from. The connection stores the selected branch and source repository with the app.

Status events and pull request comments

Enable deployment status events and pull request comments when you want repository activity to show whether a StackMachine deploy is healthy.

Auditable source history

Git deploys make every release traceable to the commit, branch, and repository that produced it. That is useful for production rollbacks, review, and support investigations.

Common workflow

  1. Deploy or retrieve the StackMachine app you want to connect.
  2. Install the StackMachine GitHub app for the target repository and capture the installation repository ID.
  3. Call client.apps.git.connect with the app ID, installation repository ID, and deploy branch.
  4. Use client.apps.git.update when you need to change the branch, deployment status events, or pull request comments.

SDK examples

Connect a repository

Connect an app to a GitHub installation repository and select the branch that should deploy.

manageAppGitConnection.js
1
const appId = "da_XYZ";
2
 
3
const connection = await client.apps.git.connect({
4
  app: appId,
5
  installationRepoId: "github_repo_installation_id",
6
  deployBranch: "main",
7
});
8
// Should return: {// { ... }
14
console.log(connection.id, connection.deployBranch);
15
console.log(connection.githubRepoInstallation.repoUrl);

Tune deploy feedback

Update the connection after it exists. Retrieve it when you need to show current branch and connection metadata.

manageAppGitConnection.js
1
const updated = await client.apps.git.update("da_XYZ", {
2
  deployBranch: "main",
3
  deploymentStatusEvents: true,
4
  pullRequestComments: true,
5
});
6
// Should return the updated GitHub repository connection.
7
console.log(updated.deployBranch, updated.deploymentStatusEvents);
8
 
9
const current = await client.apps.git.retrieve("da_XYZ");
10
console.log(current.connectedAt, current.connectedBy.username);
11
 
12
// Disconnect when the app should no longer deploy from this repository.
13
// await client.apps.git.del("da_XYZ");

Source: stackmachine/sdks  JavaScript examples.