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



                                                                                                                          
                                                            
        
                             
                                         
                                 

                                 
 











                                               








                                              
 





                                                        
 




                                           
 







                                                                                     
- name: Set up project
  vars:
    project_url: '{{ project.url | default(project) }}'
    project_name: "{{ project.name | default(project_url | urlsplit('path') | basename | regex_replace('\\.git$', '')) }}"
    project_dir: '{{ my_workspace_dir }}/{{ project_name }}'
  block:
    - name: Update repository
      ansible.builtin.git: # noqa: latest
        repo: '{{ project_url }}'
        dest: '{{ project_dir }}'
        accept_hostkey: true

    - name: Configure git repository
      community.general.git_config:
        scope: local
        repo: '{{ project_dir }}'
        name: '{{ item.name }}'
        value: '{{ item.value }}'
      loop:
        - name: user.name
          value: '{{ my_workspace_git_name }}'
        - name: user.email
          value: '{{ my_workspace_git_email }}'

    - name: Set the project running
      when: not my_workspace_clone_only
      block:
        - 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_v2:
            project_src: '{{ project_dir }}'
            pull: always
            build: always
            remove_orphans: true
          when: makefile_check is not succeeded and docker_compose_check is succeeded