zuul-jobs/roles/promote-docker-image/tasks/promote-retag-inner.yaml

32 lines
1.2 KiB
YAML

- name: Set promote_tag_prefix
set_fact:
promote_tag_prefix: "{{ ('change_' + zuul.change) if (zuul.change is defined) else zuul.pipeline }}"
- name: Get manifest
no_log: true
uri:
url: "https://registry.hub.docker.com/v2/{{ zj_image.repository }}/manifests/{{ promote_tag_prefix }}_{{ zj_image_tag }}"
status_code: 200
headers:
Accept: "application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.docker.distribution.manifest.v2+json"
Authorization: "Bearer {{ token.json.token }}"
return_content: true
register: manifest
- name: Put manifest
no_log: true
uri:
url: "https://registry.hub.docker.com/v2/{{ zj_image.repository }}/manifests/{{ zj_image_tag }}"
method: PUT
status_code: 201
body: "{{ manifest.content | string }}"
headers:
Content-Type: "{{ manifest.content_type }}"
Authorization: "Bearer {{ token.json.token }}"
- name: Delete the current change tag
no_log: true
uri:
url: "https://hub.docker.com/v2/repositories/{{ zj_image.repository }}/tags/{{ promote_tag_prefix }}_{{ zj_image_tag }}/"
method: DELETE
status_code: [200, 204]
headers:
Authorization: "JWT {{ jwt_token.json.token }}"