Deployment with the new Trellis hooks

Thanks for pointing out the outdated example project docs. Would you mind opening an issue on that repo as a reminder?

Couple points:

  • Per the docs you should keep your custom hooks outside of the roles folder. Example: deploy_build_before: "{{ playbook_dir }}/deploy-hooks/build-before.yml"

  • If you were using the local commands before, you’ll need to add some additional things to the hook file to make them run locally. And you still want to use project.local_path.

---
- name: Run npm install
  command: npm install
  connection: local
  args:
    chdir: "{{ project.local_path }}/web/app/themes/footprint"
- name: Run bower install
  command: bower install
  connection: local
  args:
    chdir: "{{ project.local_path }}/web/app/themes/footprint"
- name: Run gulp
  command: gulp --production
  connection: local
  args:
    chdir: "{{ project.local_path }}/web/app/themes/footprint"
- name: Copy project local files
  synchronize: src="{{ item.src }}"
               dest="{{ deploy_helper.new_release_path }}/{{ item.dest }}"
               group=no
               owner=no
               rsync_opts=--chmod=Du=rwx,--chmod=Dg=rx,--chmod=Do=rx,--chmod=Fu=rw,--chmod=Fg=r,--chmod=Fo=r
  with_items:
  - src: "{{ project.local_path }}/web/app/themes/footprint/dist"
    dest: web/app/themes/sage
1 Like