Skip to content

Protected branches API: support `deploy_key_id`

What does this MR do and why?

Contributes to #354657 (closed)

Problem

It's possible to modify deploy_key_id via UI, but this functionality is missing for REST API.

Solution

Allow to accept deploy_key_id for Allowed to push settings.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

  1. Create a deploy key (see guide).
  2. Enable a deploy key for the project with write permissions Screenshot_2024-09-23_at_14.31.43
  3. Discover a deploy key id via API (example: http://gdk.test:3000/api/v4/projects/<project_id>/deploy_keys)
  4. Create a protected branch with a deploy key
    curl --request POST --header "PRIVATE-TOKEN: <private-token>" "http://gdk.test:3000/api/v4/projects/<project_id>/protected_branches?name=*-stable&allowed_to_push%5B%5D%5Bdeploy_key_id%5D=<deploy_key_id>"
  5. You should see a new protected branch record with a deploy key

Screenshot_2024-09-23_at_14.35.22

Edited by Vasilii Iakliushin

Merge request reports

Loading