Monty Taylor dfb3884440 Upload images to dockerhub with buildx when using buildx
If we build multi-arch images with buildx we also need to push to
dockerhub using buildx, because otherwise we're just pushing
the single-arch image we fetched back from the buildset registry
for the local cache.

Change-Id: If8b95a708e4f0d24e959317b803f5c9379a8b62b
2020-05-07 09:23:56 -05:00

32 lines
937 B
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 dockerhub
command: "docker login -u {{ docker_credentials.username }} -p {{ docker_credentials.password }}"
no_log: true
- 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