//native
type Digitalocean = {
token: string;
};
/**
* Create an App Deployment
* Creating an app deployment will pull the latest changes from your repository and schedule a new deployment for your app.
*/
export async function main(
auth: Digitalocean,
app_id: string,
body: { force_build?: false | true },
) {
const url = new URL(
`https://api.digitalocean.com/v2/apps/${app_id}/deployments`,
);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 536 days ago