From bd1ee925425bb03f554eeb7250552dd1fc9b900e Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Thu, 7 May 2020 17:01:35 -0500 Subject: [PATCH] Process siblings in upload-image push Otherwise the context might be different and we might have to rebuild, which would be silly. I mean, not like this isn't silly already. Change-Id: I3651390581ad1b4ae66ed336825f60284bd7c4ad --- roles/upload-docker-image/tasks/buildx.yaml | 3 ++ roles/upload-docker-image/tasks/siblings.yaml | 28 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 roles/upload-docker-image/tasks/siblings.yaml diff --git a/roles/upload-docker-image/tasks/buildx.yaml b/roles/upload-docker-image/tasks/buildx.yaml index 3df9c8536..ad87b4959 100644 --- a/roles/upload-docker-image/tasks/buildx.yaml +++ b/roles/upload-docker-image/tasks/buildx.yaml @@ -1,3 +1,6 @@ +- name: Set up siblings + include_tasks: siblings.yaml + - name: Upload tag to dockerhub # docker buildx doesn't have a separate push command, only the # ability to push at the end of a build. We run build here with diff --git a/roles/upload-docker-image/tasks/siblings.yaml b/roles/upload-docker-image/tasks/siblings.yaml new file mode 100644 index 000000000..896f96387 --- /dev/null +++ b/roles/upload-docker-image/tasks/siblings.yaml @@ -0,0 +1,28 @@ +- name: Check sibling directory + stat: + path: '{{ zuul_work_dir }}/{{ zj_image.context }}/.zuul-siblings' + register: _dot_zuul_siblings + +# This should have been cleaned up; multiple builds may specify +# different siblings to include so we need to start fresh. +- name: Check for clean build + assert: + that: not _dot_zuul_siblings.stat.exists + +- name: Create sibling source directory + file: + path: '{{ zuul_work_dir }}/{{ zj_image.context }}/.zuul-siblings' + state: directory + mode: 0755 + when: zj_image.siblings is defined + +# NOTE(ianw): could use recursive copy: with remote_src, but it's +# Ansible 2.8 only. take the simple approach. +- name: Copy sibling source directories + command: + cmd: 'cp --parents -r {{ zj_sibling }} {{ ansible_user_dir }}/{{ zuul_work_dir }}/{{ zj_image.context }}/.zuul-siblings' + chdir: '~/src' + loop: '{{ zj_image.siblings }}' + loop_control: + loop_var: zj_sibling + when: zj_image.siblings is defined