I use Gridsome for Static Site Generation and I integrated Bitbucket with Netlify, so when I add a new commit it directly redeploys my site with the latest commit. Sometimes I need to redeploy without any changes in the project files, just to get the latest changes in the Database.
I want to add a button to my site when click, it uses Netlify API for redeploying with the latest Git commit, How can I do that with Netlify API?
To get the same behavior of redeploying with last commit or last deploy
First, I have to get the last deploy id for this branch
const deploys = await this.$axios.get(`https://api.netlify.com/api/v1/sites/***siteId***/deploys?page=1&per_page=1&branch=***branchName***`, {
headers: {
"Authorization": `Bearer ${token}`
}
});
Then we retry this specific deployment with this code.
await this.$axios.post(`https://api.netlify.com/api/v1/deploys/${deploys.data[0].id}/retry`, {}, {
headers
})