aboutsummaryrefslogblamecommitdiffstatshomepage
path: root/roles/workspace/tasks/project.yml
blob: 078ceead7a46da2b094acf35088dc92f72fc6b62 (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: 'Rebuild containers: {{ project_name }}'
  become: true
  block:
    - name: docker-compose pull
      ansible.builtin.command: docker-compose pull
      args:
        chdir: '{{ project_dir }}'

    - name: docker-compose build
      ansible.builtin.command: docker-compose build --force-rm --pull -q
      args:
        chdir: '{{ project_dir }}'

    - name: docker-compose up
      ansible.builtin.command: docker-compose up --remove-orphans -d
      args:
        chdir: '{{ project_dir }}'