Closed martin-josef closed 2 years ago
Hello @martin-josef ,
I've studied a bit around this one, and this is what should be possible to achive:
global:
sql_adapter: 'wpcli'
<% if ENV.fetch('FOO', nil) %>
foo: &foo
- where: remote
command: 'ls -la && pwd'
raise: true
<% else %>
foo: &foo
<% end %>
local:
vhost: "http://localhost:8080"
wordpress_path: "<%= ENV['WORDPRESS_WORKS_PATH'] %>/sshwordmove" # use an absolute path here
database:
name: "sshwordmove"
user: "root"
password: ""
host: "localhost"
production:
vhost: "http://xxx.welaika.com"
wordpress_path: "/home/sshwordmove/xxx.welaika.com" # use an absolute path here
database:
name: "xxx"
user: "xxx"
password: "xxx"
host: "xxx"
exclude:
# [...]
ssh:
host: "xxx.welaika.com"
user: "sshwordmove"
rsync_options: "--verbose"
hooks:
pull:
after: *foo
forbid:
push:
languages: true
This way you should be able to put
FOO=1
into you .env
or directly
FOO=1 wordmove pull -l
The countereffect is that wordmove doctor
will report
▬▬ Validating movefile section: global ▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬
❌ error | [/foo] key 'foo:' is undefined.
But it seems an acceptable one to me.
This is much appreciated, thanks! Interesting approach, I will play with it a bit.
Oh well... "keep it simple stupid" approach could even be better @martin-josef
hooks:
pull:
after:
<% if ENV.fetch('FOO', nil) %>
- where: remote
command: 'ls -la && pwd'
raise: true
<% end %>
I wrote a new wiki section in order to document this trick https://github.com/welaika/wordmove/wiki/YAML-tips#conditionally-composing-movefileyml
Is your feature request related to a problem? Please describe.
I use one movefile.yml for all kinds of hosts and specify the details in a .env-file. Hooks however I only run on DigitalOcean, not, for example, on Kinsta.
Describe the solution you'd like Is there a way to enable / disable hooks via .env to be able to keep them as part of my general movefile?
Describe alternatives you've considered Using separate movefiles, which is perfectly fine.
These are the hooks I use, at this point only related to ownership / permissions.