Varying build-before for multiple sites on a server

I have two sites within a Trellis-managed server:

trellis
example.com
example2.com

I want to run certain build_before tasks for each deploy

./bin/deploy.sh env example.com
./bin/deploy.sh env example2.com

In this case the only change are the paths to the theme directories:

- name: Install npm dependencies site one
  command: yarn
  delegate_to: localhost
  args:
    chdir: "{{ project_local_path }}/web/app/themes/example-theme"

etc...

- name: Install npm dependencies site two
  command: yarn
  delegate_to: localhost
  args:
    chdir: "{{ project_local_path }}/web/app/themes/example-two-theme"

etc...

I imagine I need to check for the wordpress_sites value, but Iā€™m not sure how or where I would reference that key and make the comparison.

Okay found the solution here in discourse. Just needed to know to search for deploy_build_before:

Alter file: roles/deploy/defaults.yml:

deploy_build_before:
  - "{{ playbook_dir }}/deploy-hooks/sites/{{ site }}-build-before.yml" 
  # potentially also - "{{ playbook_dir }}/deploy-hooks/build-before.yml"
1 Like

This topic was automatically closed after 42 days. New replies are no longer allowed.