--- # Build one node/vite static site into {{ web_static_root }}/_. # Called per item with loop_var app_item = { name, env, port }. # The app's own `npm run build:` script is expected to output to # {{ web_static_root }}/_dta_webapp. - name: "static[{{ app_item.name }}/{{ app_item.env }}] locals" ansible.builtin.set_fact: _spec: "{{ app_catalog[app_item.name] }}" _src: "{{ apps_src_dir }}/{{ app_item.name }}_{{ app_item.env }}" _webroot: "{{ (app_catalog[app_item.name].webroot_pattern | default(web_static_root ~ '/{env}_' ~ app_item.name)) | replace('{env}', app_item.env) }}" _ref: "{{ app_ref | default(app_catalog[app_item.name].default_branch) }}" - name: "static[{{ app_item.name }}/{{ app_item.env }}] workdir" ansible.builtin.set_fact: _workdir: "{{ (_src ~ '/' ~ _spec.subdir) if (_spec.subdir | default('')) else _src }}" - name: "static[{{ app_item.name }}/{{ app_item.env }}] ensure dirs" ansible.builtin.file: path: "{{ item }}" state: directory owner: "{{ admin_user }}" group: "{{ admin_user }}" mode: "0755" loop: - "{{ apps_src_dir }}" - "{{ _webroot }}" - name: "static[{{ app_item.name }}/{{ app_item.env }}] checkout {{ _ref }}" ansible.builtin.git: repo: "{{ _spec.repo }}" dest: "{{ _src }}" version: "{{ _ref }}" force: true accept_hostkey: true become: true become_user: "{{ admin_user }}" - name: "static[{{ app_item.name }}/{{ app_item.env }}] npm ci" ansible.builtin.command: cmd: npm ci chdir: "{{ _workdir }}" become: true become_user: "{{ admin_user }}" changed_when: true - name: "static[{{ app_item.name }}/{{ app_item.env }}] build ({{ app_item.env }})" ansible.builtin.command: cmd: "npm run build:{{ app_item.env }}" chdir: "{{ _workdir }}" become: true become_user: "{{ admin_user }}" changed_when: true