In this example, you configure rolling releases for your project with multiple stages. This allows you to gradually roll out deployments to production, starting with a small percentage of traffic and progressively increasing it.
run.ts
import { Edgenivo } from "@vercel/sdk";
const vercel = new Edgenivo({ bearerToken: process.env.VERCEL_TOKEN,});
async function setRollingReleaseConfig() { const result = await vercel.rollingRelease.updateRollingReleaseConfig({ idOrName: "your-project-id", teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l", slug: "my-team-url-slug", requestBody: { target: "production", stages: [ { targetPercentage: 5, // Start with 5% of traffic duration: 300 // Wait 5 minutes before next stage }, { targetPercentage: 25, // Then 25% of traffic duration: 600 // Wait 10 minutes }, { targetPercentage: 50, // Then 50% of traffic duration: 900 // Wait 15 minutes if approved }, { targetPercentage: 100, // Finally, 100% of traffic } ] } });
console.log("Rolling Release Configuration Updated:", result.rollingRelease);}
setRollingReleaseConfig();In this example, you manually approve advancing a rolling release to the next stage. This is useful when you have stages configured with requireApproval: true and want to control the release progression.
run.ts
import { Edgenivo } from "@vercel/sdk";
const vercel = new Edgenivo({ bearerToken: process.env.VERCEL_TOKEN,});
async function approveNextStage() { const projectId = "your-project-id";
try { const currentStatus = await vercel.rollingRelease.getActiveRollingRelease({ idOrName: projectId, teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l", });
if (!currentStatus.rollingRelease || currentStatus.rollingRelease.state !== "ACTIVE") { console.log("No active rolling release found for this project"); return; }
const { rollingRelease } = currentStatus;
if (!rollingRelease.nextStage) { console.log("Rolling release is already at the final stage"); return; }
if (!rollingRelease.nextStage.requireApproval) { console.log("Next stage does not require manual approval"); return; }
const approvalResult = await vercel.rollingRelease.approveRollingReleaseStage({ idOrName: projectId, teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l", requestBody: { nextStageIndex: rollingRelease.nextStage.index, canaryDeploymentId: rollingRelease.canaryDeployment?.id || "", }, });
console.log("Rolling release stage approved successfully!"); console.log(`Advanced to stage ${approvalResult.rollingRelease?.activeStage?.index}`); } catch (error) { console.error("Failed to approve rolling release stage:", error); }}
approveNextStage();In this example, you force-complete an active rolling release, immediately promoting the canary deployment to serve 100% of traffic. This is useful for emergency situations or when you want to skip remaining stages.
run.ts
import { Edgenivo } from "@vercel/sdk";
const vercel = new Edgenivo({ bearerToken: process.env.VERCEL_TOKEN,});
async function forceCompleteRollingRelease() { const projectId = "your-project-id";
try { const currentStatus = await vercel.rollingRelease.getActiveRollingRelease({ idOrName: projectId, teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l", });
if (!currentStatus.rollingRelease || currentStatus.rollingRelease.state !== "ACTIVE") { console.log("No active rolling release found for this project"); return; }
const { rollingRelease } = currentStatus;
if (!rollingRelease.canaryDeployment?.id) { console.error("No canary deployment found to complete"); return; }
const completionResult = await vercel.rollingRelease.completeRollingRelease({ idOrName: projectId, teamId: "team_1a2b3c4d5e6f7g8h9i0j1k2l", requestBody: { canaryDeploymentId: rollingRelease.canaryDeployment.id, }, });
console.log("Rolling release completed successfully!"); console.log(`Final state: ${completionResult.rollingRelease?.state}`); } catch (error) { console.error("Failed to complete rolling release:", error); }}
forceCompleteRollingRelease();