zuul-jobs/roles/upload-docker-image/tasks/main.yaml
Paul Belanger c3309e045a Always log out of docker registry after upload
Make sure we always log out of the docker registry, as not to allow
other playbooks to use the session.

Change-Id: I65fb71884b08802b5537ecef7304129cdeb952c3
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2020-11-12 14:01:57 -05:00

37 lines
1.1 KiB
YAML

- name: Verify repository names
when: |
docker_credentials.repository is defined
and not zj_image.repository | regex_search(docker_credentials.repository)
loop: "{{ docker_images }}"
loop_control:
loop_var: zj_image
fail:
msg: "{{ zj_image.repository }} not permitted by {{ docker_credentials.repository }}"
- name: Log in to registry
command: "docker login -u {{ docker_credentials.username }} -p {{ docker_credentials.password }} {{ docker_registry }}"
no_log: true
- name: Publish docker images
block:
- name: Determine if we need to use buildx
set_fact:
use_buildx: "{{ docker_images | selectattr('arch', 'defined') | list }}"
- name: Upload image to dockerhub normally
loop: "{{ docker_images }}"
loop_control:
loop_var: zj_image
include_tasks: push.yaml
when: not use_buildx
- name: Upload image to dockerhub using buildx
loop: "{{ docker_images }}"
loop_control:
loop_var: zj_image
include_tasks: buildx.yaml
when: use_buildx
always:
- name: Log out of registry
command: "docker logout {{ docker_registry }}"