How to Automate Git Deployment Using Webhooks on Cloudways


#1

Hi All,

So I have been ‘playing’ about with webhooks and auto deployment as stated here https://support.cloudways.com/how-to-automate-git-deployment-using-webhooks/ the thing is I think it would be best for the script to take a backup before deploying. So I have added that like this…

`// Backup server
$accessToken = $tokenResponse->access_token;
$serverBackup = callCloudWaysAPI(‘POST’, ‘/server/manage/backup’, $accessToken, [
‘server_id’ => $_GET[‘server_id’]
]);

echo ("backup started: ".json_encode($serverBackup));`

However, I would like it only then deploy once the backup is complete.

Can anyone help me with that? I can’t seem to figure it out.

Thanks