blob: 3c1d043702704d0a0edb7dd21fe4008a48803206 [file] [log] [blame]
- name: Build images
block:
- name: Create metadata file
ansible.builtin.tempfile:
state: file
prefix: metadata
suffix: .json
register: depot_bake_metadata_file
- name: Run "depot bake"
ansible.builtin.command: >-
{{ ensure_depot_path | default('/usr/local/bin') }}/depot bake --push --metadata-file={{ depot_bake_metadata_file.path }}
args:
chdir: "{{ zuul.project.src_dir }}"
environment: "{{ _depot_bake_environment | combine(depot_bake_environment) }}"
- name: Slurp the metadata file
ansible.builtin.slurp:
src: "{{ depot_bake_metadata_file.path }}"
register: depot_bake_metadata
- name: Unmarshal the metadata file
ansible.builtin.set_fact:
depot_bake_metadata: "{{ depot_bake_metadata.content | b64decode | from_json }}"
- name: Build empty list of artifacts
ansible.builtin.set_fact:
depot_bake_artifacts: []
- name: Append each artifact to the list
ansible.builtin.set_fact:
depot_bake_artifacts: "{{ depot_bake_artifacts + [depot_bake_artifact] }}"
loop: "{{ depot_bake_metadata | dict2items }}"
loop_control:
label: "{{ item.key }}"
when:
- item.key != "depot.build"
- item.value != {}
- item.value["image.name"] is defined
vars:
depot_bake_artifact:
name: "{{ item.value['image.name'] }}"
url: "docker://{{ item.value['image.name'] }}"
metadata:
type: container_image
repository: "{{ item.value['image.name'] | split(':') | first }}"
tag: "{{ item.value['image.name'] | split(':') | last }}"
- name: Return artifacts for each image
zuul_return:
data:
zuul:
artifacts: "{{ depot_bake_artifacts }}"
always:
- name: Cleanup metadata file
ansible.builtin.file:
path: "{{ depot_bake_metadata_file.path }}"
state: absent