-
Notifications
You must be signed in to change notification settings - Fork 6
/
gitops_on_push.yml
38 lines (34 loc) · 1.16 KB
/
gitops_on_push.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
---
- name: Push -- update application repo
hosts: localhost
gather_facts: false
tasks:
- name: Push -- Check if repo exists locally
ansible.builtin.stat:
path: "/tmp/{{ ansible_eda.event.repo_name }}"
register: repo_stat
- name: Push -- Clone application repository
ansible.builtin.git:
repo: "{{ ansible_eda.event.clone_url }}"
dest: "/tmp/{{ ansible_eda.event.repo_name }}"
clone: true
update: true
when: repo_stat.stat.exists == false
register: repo_cloned
- name: Push -- Update application repository to event ref
ansible.builtin.git:
repo: "{{ ansible_eda.event.clone_url }}"
dest: "/tmp/{{ ansible_eda.event.repo_name }}"
clone: true
update: true
version: "{{ ansible_eda.event.gitref | split('/') | last }}"
register: repo_cloned
- name: Set Facts
ansible.builtin.set_fact:
cacheable: true
repo_stat: "{{ repo_stat }}"
cloned: "{{ repo_cloned }}"
etype: "{{ ansible_eda.event.type }}"
erepo: "{{ ansible_eda.event.repo_name }}"
eref: "{{ ansible_eda.event.gitref | split('/') | last }}"
eauthor: "{{ ansible_eda.event.author }}"