forked from vstconsulting/polemarch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_release.yml
73 lines (64 loc) · 1.88 KB
/
docker_release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
- hosts: docker[0]
vars:
ansible_python_interpreter: "/usr/bin/env python"
registry_image: "{{ registry_url }}/{{ registry_image_name }}"
polemarch_version: "{{tag}}"
dockerhost: "{% if docker_host %}{{docker_host}}{% else %}unix:///var/run/docker.sock{% endif %}"
handlers:
- name: build registry
docker_image:
path: ./
name: "{{ registry_image }}"
tag: "{{ docker_tag }}"
docker_host: "{{dockerhost}}"
timeout: 600
push: yes
listen: "build registry"
- name: build dockerhub
docker_image:
path: ./
name: "{{ dockerhub_image_name }}"
tag: "{{ docker_tag }}"
docker_host: "{{dockerhost}}"
timeout: 600
push: yes
listen: "build dockerhub"
tasks:
- name: Set Docker image tag
set_fact:
docker_tag: "{{tag}}"
- name: Login into git registry
docker_login:
username: "{{ registry_username }}"
password: "{{ registry_password }}"
registry: "{{ registry_url }}"
docker_host: "{{dockerhost}}"
reauthorize: yes
timeout: 600
notify:
- "build registry"
- meta: flush_handlers
- name: Login into dockerhub
docker_login:
username: "{{ dockerhub_username }}"
password: "{{ dockerhub_password }}"
email: "{{ dockerhub_email }}"
docker_host: "{{dockerhost}}"
reauthorize: yes
timeout: 600
changed_when: true
notify:
- "build dockerhub"
- meta: flush_handlers
- name: Get latest release tag
shell: git describe --tags `git rev-list --tags --max-count=1`
register: release_latest_version
- name: Set latest tag
set_fact:
docker_tag: 'latest'
changed_when: release_latest_version.stdout == tag
notify:
- "build registry"
- "build dockerhub"
- meta: flush_handlers