Edits history of script submission #18713 for ' Roll back deploy (render)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Render = {
    	apiKey: string
    }
    /**
     * Roll back deploy
     * Trigger a rollback to a previous deploy of the specified service.
    
    Triggering a rollback with this endpoint does not disable autodeploys for the service. This means an autodeploy might restore changes you had intentionally rolled back.
    
    You can toggle autodeploys for your service with the [Update service](https://api-docs.render.com/reference/update-service) endpoint or in the Render Dashboard.
    
     */
    export async function main(auth: Render, serviceId: string, body: { deployId: string }) {
    	const url = new URL(`https://api.render.com/v1/services/${serviceId}/rollback`)
    
    	const response = await fetch(url, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		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 235 days ago