---
- name: Dependencies installed
  community.general.pkgng:
    name: git-tiny,yarn
    state: latest
  tags:
    - build

- name: Source folder exists
  file: path=/usr/local/src mode=0755 state=directory
  tags:
    - build

- name: Excalidraw source fetched
  git:
    repo: "https://github.com/excalidraw/excalidraw.git"
    dest: /usr/local/src/excalidraw
    force: yes
    accept_hostkey: yes
    update: yes
  tags:
    - build

- name: Yarn dependencies installed
  shell:
    chdir: /usr/local/src/excalidraw
    cmd: yarn && yarn build

- name: Excalidraw build artifacts installed
  shell:
    cmd: mkdir -p /usr/local/www/excalidraw && cp -r /usr/local/src/excalidraw/build/* /usr/local/www/excalidraw/
  tags:
    - build

- name: Nginx config file installed
  ansible.builtin.copy:
    src: nginx-location.conf
    dest: /usr/local/etc/nginx/locations/
  notify: Nginx restarted
