Is there a way to re-deploy an app via a URL?

Basically, I need a way to redeploy an app without having to log into DO’s Platform App Dashboard and clicking the Deploy button, or by making code changes to the repo attached to the app.

Similar to:

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
2 answers

👋 @jesscjohnson

Currently you can trigger a deployment by making a call to our API to create a new deployment.

For example:

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer b7d03a6947b217efb6f3ec3bd3504582" "https://api.digitalocean.com/v2/apps/{app_id}/deployments" 

🔗 Full API docs

Our doctl commandline tool can also be used to trigger a new deployment:

doctl apps create-deployment <app id>

🔗 AP doctl docs

Thanks for linking those documents, I will take this back to the team and see if we can plan out a feature for offering a webhook like implementation to make this easier.

Happy hacking!

  • Thanks for this, but how do you get the app id? Trying what you suggested, I keep getting getting a 401.

    {"id": "Unauthorized", "message": "Unable to authenticate you" } 
    

    I can’t figure out if the problem is the app id or the token I’m trying to use. For the app id, I’ve tried both my app name and the ondigitalocean.app subdomain but neither work (i.e. my-app-name-mc2-j.ondigitalocean.app)

    For the token, I simply created one in cloud.digitalocean.com/account/api/tokens and am using the secret for the auth token.

    So my request looks like:

    curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer {my_secret_token}" "https://api.digitalocean.com/v2/apps/{my-app-name}/deployments"
    

    But it doesn’t work....

    • Wooks, got this working now. Was using key instead of a token 🤦.

      I eventually got my app id by querying the api for all apps:

      curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer {secret_token}" "https://api.digitalocean.com/v2/apps"
      

      However, it seems like it would be nice to make this available in the dashboard?

Thanks @crashoverride! That’s very helpful.

Offering a web hook would be a great feature addition for folks that can’t use that API/doctl, but this way works enough for my use case.

Cheers

Submit an Answer