Update an existing app by passing a new files map and setting allowExistingApp / allow_existing_app to true.
Start a deployment
allowExistingApp / allow_existing_app is required when the app name already exists in your namespace.
redeployFromFiles.jsredeploy.py
// Request: appName, owner, files, allowExistingApp: true
const deployment = await client.deployments.create({
appName: "hello-stackmachine",
owner: "stackmachine",
allowExistingApp: true, // required when redeploying an app that already exists
files: {
"index.html": "<html><body><h1>Updated</h1></body></html>",
},
});
// Should return: {
// "buildId": "build_abc123",
// "status": "QUEUED",
// "appVersion": null
// }
console.log(deployment.buildId, deployment.status);deployment = client.deployments.create(
app_name="hello-stackmachine",
owner="stackmachine",
allow_existing_app=True, # required when redeploying an app that already exists
files={"index.html": "<html><body><h1>Updated</h1></body></html>"},
)
# Should return: {
# "build_id": "build_abc123",
# "status": "QUEUED",
# "app_version": null
# }
print(deployment.build_id, deployment.status)Wait for the build
Same as a first deploy: call wait() on the returned deployment until the new version is live.
redeployFromFiles.jsredeploy.py
const appVersion = await deployment.wait({
onProgress: ({ kind, message }) => console.log(kind, message),
});
// Should return: {
// "id": "dv_xyz789",
// "app": { "url": "https://hello-stackmachine.stackmachine.app" }
// }
console.log(appVersion.app.url);app_version = deployment.wait(on_progress=lambda e: print(e.kind, e.message))
# Should return: {
# "id": "dv_xyz789",
# "app": { "url": "https://hello-stackmachine.stackmachine.app" }
# }
print(app_version.app.url)Source: stackmachine/sdks examples.