49 lines
1.3 KiB
YAML
49 lines
1.3 KiB
YAML
---
|
|
- name: Get {{ image.repo_name }} repo's last commit
|
|
ansible.builtin.git:
|
|
repo: "{{ image.repo_url }}"
|
|
clone: no
|
|
update: no
|
|
version: master
|
|
register: git
|
|
changed_when: false
|
|
|
|
- name: Set fact commit
|
|
set_fact:
|
|
commit: "{{ git.after[0:10] }}"
|
|
|
|
- debug: var=commit
|
|
|
|
# podman logout is needed before podman login if registry was recreated
|
|
- name: Logout from registry
|
|
containers.podman.podman_logout:
|
|
registry: "{{ image.push_dest }}"
|
|
changed_when: false
|
|
become: true
|
|
when: image.push | default(False) | bool
|
|
|
|
- name: Login to registry and create ${XDG_RUNTIME_DIR}/containers/auth.json
|
|
containers.podman.podman_login:
|
|
username: "{{ image.push_user }}"
|
|
password: "{{ image.push_pwd }}"
|
|
registry: "{{ image.push_dest }}"
|
|
changed_when: false
|
|
become: true
|
|
when: image.push | default(False) | bool
|
|
|
|
- name: Build {{ image.name }} image
|
|
containers.podman.podman_image:
|
|
name: "{{ image.name }}:{{ commit }}"
|
|
path: "{{ image.repo_url }}"
|
|
build:
|
|
force_rm: true
|
|
push: "{{ image.push | default(False) | bool }}"
|
|
push_args:
|
|
dest: "{{ image.push_dest | default('') }}"
|
|
become: true
|
|
register: result
|
|
|
|
- name: Set fact {{ image.result_var }}
|
|
set_fact:
|
|
"{{ image.result_var }}": "{{ result }}"
|