diff --git a/tools/ansible/deploy/after-update-code.yml b/tools/ansible/deploy/after-update-code.yml index fb83f5a..9f1f679 100644 --- a/tools/ansible/deploy/after-update-code.yml +++ b/tools/ansible/deploy/after-update-code.yml @@ -31,25 +31,4 @@ register: config_import_result changed_when: "'There are no changes to import' not in config_import_result.stderr" -- name: Generate front-end assets - command: | - {{ item.command }} - chdir={{ release_theme_path }} - creates="{{ item.creates }}" - with_items: - - command: "{{ release_drush_path }} opdavies:export-body-values-for-theme-purging" - creates: "{{ release_theme_path }}/body-field-values.txt" - - - command: npm install - creates: "{{ release_theme_path }}/node_modules" - - - command: npm run production - creates: "{{ release_theme_path }}/dist" - -- name: Remove files that are no longer needed - file: - path: "{{ release_theme_path }}/{{ item }}" - state: absent - with_items: - - body-field-values.txt - - node_modules +- include: ../includes/build-theme-assets.yml diff --git a/tools/ansible/includes/build-theme-assets.yml b/tools/ansible/includes/build-theme-assets.yml new file mode 100644 index 0000000..b7deb9d --- /dev/null +++ b/tools/ansible/includes/build-theme-assets.yml @@ -0,0 +1,26 @@ +--- +- name: Export body values to include in theme purging + command: > + {{ release_drush_path }} opdavies:export-body-values-for-theme-purging + chdir={{ release_theme_path }} + creates={{ release_theme_path }}/body-field-values.txt + +- name: Install theme dependencies + command: > + npm install + chdir={{ release_theme_path }} + creates={{ release_theme_path }}/node_modules + +- name: Generate front-end assets + command: > + npm run production + chdir={{ release_theme_path }} + creates={{ release_theme_path }}/dist + +- name: Remove files that are no longer needed + file: + path: "{{ release_theme_path }}/{{ item }}" + state: absent + with_items: + - body-field-values.txt + - node_modules