Alessandro Fazzi edited this page Mar 29, 2018 · 9 revisions

You can find general hooks usage information in movefile.yml configurations explained. This is a sort of F.A.Q. before any question has been made.

Wordmove has 8 hooks which will be called if populated with commands. This is how they are represented in the movefile.yml:

  hooks: # Remote hooks won't work with FTP
    push:
      before:
        local:
          - 'echo "Do something locally before push"'
        remote:
          - 'echo "Do something remotely before push"'
      after:
        local:
          - 'echo "Do something locally after push"'
        remote:
          - 'echo "Do something remotely after push"'
    pull:
      before:
        local:
          - 'echo "Do something locally before pull"'
        remote:
          - 'echo "Do something remotely before pull"'
      after:
        local:
          - 'echo "Do something locally after pull"'
        remote:
          - 'echo "Do something remotely after pull"'

Hooks are optional. You can remove the entire hooks key from movefile.yml or you can configure just the hooks you need, erasing the others.

Each hook want a sequence - which is the YAML representation of an Array - of commands.

Commands must be quoted. Prefer single quote, since double quotes are often used inside the command self. If you won't quote commands, they will easily break our toy :)

Hooks are under the vigilance of the doctor command, so you can wordmove doctor to check their formal validation.

User interface example

hooks UI

Execution path

Remote hooks will be run in the $HOME directory of your user. If your home is not your site's document root and if you want to run, e.g. a wp command, you will have to cd by yourself:

Since v3.0.0 remote hooks will be run inside wordpress_path as per your movefile.yml configuration.

Local hooks will be run from the directory where wordmove was invoked.

Why hooks, by examples

Feel free to populate this section with yours.

hooks:
  push:
    before:
      local:
        - 'npx webpack' # run webpack to build frontend
        - 'rm -rf ./tmp/*' # blank local temp directory
    after:
      local:
        - 'bash ./scripts/slack_notify.sh' # notify colleagues/customers on Slack/Ryver chat
      remote:
        - 'wp rewrite flush' # you know that :)
        - 'wp option set blog_public 0' # hide WP from search engine on staging
        - 'find . -type f -exec chmod 664 {}+' # fix permissions and blame your hosting provider
        - 'find . -type d -exec chmod 755 {}+' # N.B.: blaming is not yet supported by Wordmove

Credits

All started a long time ago in the feature request #143, opened by @joeguilmette :) Open source not always follows our expectations or timing needs, but participating and make proposals is always inspirational. Thank you Joe!

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.