aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/roles/my_workspace/tasks/project.yml
blob: 813de4628d806a9267432d0d16ebacab8913b36f (plain) (tree)
1
2
3
4
5
6
7
8







                                                                                                                       



                                                         


                                               
                             

                             




                                      
                     
 




                                                
                     
 





                                   
                          
              





                                    
                                                                             
- name: Set project URL
  ansible.builtin.set_fact:
    project_url: '{{ item.url | default(item) }}'

- name: Set project name
  ansible.builtin.set_fact:
    project_name: "{{ item.name | default(project_url | urlsplit('path') | basename | regex_replace('\\.git$', '')) }}"

- name: Set project directory
  ansible.builtin.set_fact:
    project_dir: '{{ workspace_dir }}/{{ project_name }}'

- name: 'Update repository: {{ project_name }}'
  ansible.builtin.git:
    accept_hostkey: true
    dest: '{{ project_dir }}'
    repo: '{{ project_url }}'

- name: Check for Makefile
  ansible.builtin.file:
    path: '{{ project_dir }}/Makefile'
    state: file
  register: makefile_check
  ignore_errors: true

- name: Check for docker-compose.yml
  ansible.builtin.file:
    path: '{{ project_dir }}/docker-compose.yml'
    state: file
  register: docker_compose_check
  ignore_errors: true

- name: Run make
  become: true
  community.general.make:
    chdir: '{{ project_dir }}'
  when: makefile_check is succeeded

- name: Run docker-compose
  become: true
  community.docker.docker_compose:
    build: true
    debug: true
    project_src: '{{ project_dir }}'
    pull: true
    remove_orphans: true
  when: makefile_check is not succeeded and docker_compose_check is succeeded