I’m trying to automatically deploy a docker image after CI, by using the API.
Having tested the https://app.koyeb.com/v1/services/{id}/redeploy endpoint a fair amount, I can’t seem to be able to specify a particular image tag to deploy as part of the request.
Is this possible & I’m missing something?
It always seems to deploy the same image tag that I originally specified in the Web UI.
Hey!
The redeploy endpoint creates a new deployment with the exact same configuration as the last deployment of your service. That would explain why you can’t update the docker image there.
The endpoint to use would be PATCH /v1/services/{id} where you would patch the definition field. The recommended way to go would be to:
run GET /v1/services/{id} where id is your service ID. Then you should look for the latest_deployment_id field
run GET /v1/deployments/{id} where id is the latest_deployment_id. Then you should look for the definition field
run PATCH /v1/services/{id} where id is your service ID. You should patch the definition field with the definition retrieved from last step, with the docker image replaced to what you wanted
I had originally intended to avoid using another action package in my pipeline, but will reconsider whether it is best to continue to do so, patching the service as you’ve specified above or to use the package you have also detailed.