-
Notifications
You must be signed in to change notification settings - Fork 170
Hooks
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.
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:
- 'cd /var/www/htdocs/mysite && wp plugin list'
Local hooks will be run from the directory where wordmove
was invoked.
We are thinking about implementing an "auto-cd-to" option, but we have not a bright opinion yet.
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:
remote:
- 'wp rewrite flush' # you know that :)
- 'wp option set blog_public 0' # hide WP from search engine on staging
- 'bash ./scripts/slack_notify.sh' # notify colleagues/customers on Slack/Ryver chat
- '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
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!