40 lines
1.3 KiB
YAML
40 lines
1.3 KiB
YAML
- name: Get dockerhub token
|
|
no_log: true
|
|
uri:
|
|
url: "https://auth.docker.io/token?service=registry.docker.io&scope=repository:{{ image.repository }}:pull,push"
|
|
user: "{{ docker_credentials.username }}"
|
|
password: "{{ docker_credentials.password }}"
|
|
force_basic_auth: true
|
|
register: token
|
|
- name: Get manifest
|
|
no_log: true
|
|
uri:
|
|
url: "https://registry.hub.docker.com/v2/{{ image.repository }}/manifests/change_{{ zuul.change }}"
|
|
status_code: 200
|
|
headers:
|
|
Accept: "application/vnd.docker.distribution.manifestv2+json"
|
|
Authorization: "Bearer {{ token.json.token }}"
|
|
return_content: true
|
|
register: manifest
|
|
- name: "Put manifest"
|
|
no_log: true
|
|
loop: "{{ image.tags | default(['latest']) }}"
|
|
loop_control:
|
|
loop_var: new_tag
|
|
uri:
|
|
url: "https://registry.hub.docker.com/v2/{{ image.repository }}/manifests/{{ new_tag }}"
|
|
method: PUT
|
|
status_code: 201
|
|
body: "{{ manifest.content | string }}"
|
|
headers:
|
|
Content-Type: "application/vnd.docker.distribution.manifestv2+json"
|
|
Authorization: "Bearer {{ token.json.token }}"
|
|
- name: Delete the current change tag
|
|
no_log: true
|
|
uri:
|
|
url: "https://hub.docker.com/v2/repositories/{{ image.repository }}/tags/change_{{ zuul.change }}/"
|
|
method: DELETE
|
|
status_code: 204
|
|
headers:
|
|
Authorization: "JWT {{ jwt_token.json.token }}"
|