From bcfcd6f9a0a1442d2163cf4a0ac292c18927f40a Mon Sep 17 00:00:00 2001 From: Drew Walters Date: Wed, 12 Feb 2020 15:52:52 -0600 Subject: [PATCH] [#33] Publish airshipctl image on Quay This change introduces a job that publishes the latest airshipctl image to quay.io/airshipit/airshipctl each time a new change is merged. Closes #33 Change-Id: I8468b10a8064333d1749015960151e98adb2be97 Signed-off-by: Drew Walters --- Makefile | 4 ++ .../airship-airshipctl-publish-images.yaml | 16 +++++++ .../airshipctl-publish-images/tasks/main.yaml | 46 +++++++++++++++++++ zuul.d/jobs.yaml | 12 ++++- zuul.d/projects.yaml | 1 + zuul.d/secrets.yaml | 26 +++++++++++ 6 files changed, 103 insertions(+), 2 deletions(-) create mode 100644 playbooks/airship-airshipctl-publish-images.yaml create mode 100644 roles/airshipctl-publish-images/tasks/main.yaml diff --git a/Makefile b/Makefile index 58203a326..d43ad215b 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ DOCKER_IMAGE_PREFIX ?= airshipit DOCKER_IMAGE_TAG ?= dev DOCKER_IMAGE ?= $(DOCKER_REGISTRY)/$(DOCKER_IMAGE_PREFIX)/$(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_TAG) DOCKER_TARGET_STAGE ?= release +PUBLISH ?= false # go options PKG ?= ./... @@ -111,6 +112,9 @@ else --tag $(DOCKER_IMAGE) \ --target $(DOCKER_TARGET_STAGE) endif +ifeq ($(PUBLISH), true) + @docker push $(DOCKER_IMAGE) +endif .PHONY: print-docker-image-tag diff --git a/playbooks/airship-airshipctl-publish-images.yaml b/playbooks/airship-airshipctl-publish-images.yaml new file mode 100644 index 000000000..791af65d6 --- /dev/null +++ b/playbooks/airship-airshipctl-publish-images.yaml @@ -0,0 +1,16 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- hosts: all + become: yes + roles: + - airshipctl-publish-images diff --git a/roles/airshipctl-publish-images/tasks/main.yaml b/roles/airshipctl-publish-images/tasks/main.yaml new file mode 100644 index 000000000..af8c0aa4c --- /dev/null +++ b/roles/airshipctl-publish-images/tasks/main.yaml @@ -0,0 +1,46 @@ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +- name: Install python-docker Module + apt: + pkg: + - python-docker + - python3-requests + state: present + when: ansible_distribution == 'Debian' or ansible_distribution == 'Ubuntu' + +- name: List Docker Images + shell: docker image ls + +- name: Push Images + block: + - name: Login to Image Registry + docker_login: + username: "{{ image-repo-credentials.username }}" + password: "{{ image-repo-credentials.password }}" + registry_url: "{{ image_repo }}" + + - name: Push Image with Latest Tag + make: + chdir: "{{ zuul.project.src_dir }}" + params: + DOCKER_IMAGE_TAG: latest + PUBLISH: true + target: images + + - name: Push Image with Commit Tag + make: + chdir: "{{ zuul.project.src_dir }}" + params: + DOCKER_IMAGE_TAG: "{{ zuul.newrev }}" + PUBLISH: true + target: images diff --git a/zuul.d/jobs.yaml b/zuul.d/jobs.yaml index 72be60809..a0a5f2249 100644 --- a/zuul.d/jobs.yaml +++ b/zuul.d/jobs.yaml @@ -28,8 +28,6 @@ name: airship-airshipctl-build-image nodeset: airship-airshipctl-single-node run: playbooks/airship-airshipctl-build-images.yaml - roles: - - zuul: openstack/openstack-helm-infra irrelevant-files: - ^.*\.md$ - ^docs/.*$ @@ -86,3 +84,13 @@ vars: rtd_project_name: airship-airshipctl rtd_webhook_id: 112688 + +- job: + name: airship-airshipctl-publish-image + parent: airship-airshipctl-build-image + post-run: playbooks/airship-airshipctl-publish-images.yaml + secrets: + - airshipctl-image-repo-credentials + vars: + image: quay.io/airshipit/airshipctl + image_repo: https://quay.io/api/v1/ diff --git a/zuul.d/projects.yaml b/zuul.d/projects.yaml index 57975126b..07e79d125 100644 --- a/zuul.d/projects.yaml +++ b/zuul.d/projects.yaml @@ -28,4 +28,5 @@ post: jobs: - airship-airshipctl-publish-docs + - airship-airshipctl-publish-image - airship-airshipctl-upload-git-mirror diff --git a/zuul.d/secrets.yaml b/zuul.d/secrets.yaml index f53140256..a86666db8 100644 --- a/zuul.d/secrets.yaml +++ b/zuul.d/secrets.yaml @@ -57,3 +57,29 @@ B4PhXVzb3mTLrFcakuP4U7g7UkAbqg4CHJKuF2BiazJRZH569YFJdP0UkOXz8tSTRDTQh uPzQ1Ero9vGyHmFuvFczZK+TnJBxyKiyWr4kR9GbI3WVXMSa78M+kRqQmcnqdwS9AAFC2 595F3m2UtgR6QKN5xbJJmWp7ipihdRvQ1eVl5GCjG7MBi27YvILp4cIWg+MO1I= + +- secret: + name: airshipctl-image-repo-credentials + data: + username: !encrypted/pkcs1-oaep + - IrKFuv6QJnGT7C/c6a4GCmDLJn0rZ82ivaAd3BjP3QyTegM95gVCOFC4l45NGRLLtzFun + 43XI00cNxokj4qohxzxstjq/3SIyHZ4EKmQD+Ln/YWGk39SNbf8o9X1iUOSfn9KnpTooL + BpWS47k6VKHvba+Ksh32UvdTSIERqRzR7nFeK1y/WQp6hzo3XdoaBYhXqwbbBz141+cfB + UDGkTcNuJbJnLDL99fJpxjXm/4CtVysUaIae/VBXc4syJPb3C1AzXTQNDh82gO45QvSuM + Mj7i2G850BFRK+rE8oFhvZm8ONqVRFgSbFdzhiVkOf4JGaLP4QXZxO3Biy1Qn1OQpGGcq + gZmoLy1ldTuZvManNtgOHdpEhD7Y6Pvo893cKR/KsKRj1aqJFJTWaQZqas+4Wrk39ARZU + Xw72HS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