playbooks/build ocean.yml

31 lines
872 B
YAML

---
- name: build ocean
hosts: all
tasks:
- name: Bring down Docker Compose services
command: docker compose down
args:
chdir: "{{ item }}"
loop: "{{ extra_services }}"
- name: Go to the ocean directory
command: "chdir={{directory}} git pull origin {{branch}}"
register: git_result
- name: Build docker image if there were changes
docker_image:
source: build
build:
path: "{{directory}}"
name: ocean
tag: "{{semaphore_vars.task_details.target_version}}"
when: git_result.changed
register: build_result
ignore_errors: yes
- name: Print build result
debug:
msg: "Build failed!" # Log failure message
when: build_result.failed
- name: Bring down Docker Compose services
command: docker compose up -d
args:
chdir: "{{ item }}"
loop: "{{ extra_services }}"