Specify Image tag during (re)deploy

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:

  1. run GET /v1/services/{id} where id is your service ID. Then you should look for the latest_deployment_id field
  2. run GET /v1/deployments/{id} where id is the latest_deployment_id. Then you should look for the definition field
  3. 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

Another easier option would maybe be to use Koyeb GitHub action: GitHub - koyeb-community/koyeb-actions: An Action to install and configure koyeb cli. You would just need to do something like

      - name: Install and configure the Koyeb CLI
        uses: koyeb-community/koyeb-actions@v2
        with:
          api_token: "${{ secrets.KOYEB_TOKEN }}"
          github_token: "${{ secrets.GITHUB_TOKEN }}"
      - name: Update Docker Image
        run: koyeb service update <my_app>/<my_service> --docker <my_new_docker_image>
1 Like

Hi Nicolas,

Thanks for your response, this all makes sense.

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.

Thanks for your prompt response.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.