welaika / wordmove

Multi-stage command line deploy/mirroring and task runner for Wordpress
https://wptools.it/wordmove
MIT License
1.87k stars 165 forks source link

Execute local shell script on remote machine? (Hooks) #610

Closed martin-josef closed 4 years ago

martin-josef commented 4 years ago

Hey everyone,

I execute a few commands after pushing a site to make sure permissions etc. are correct. I would like to do some slightly more elaborate things, is it possible to execute a shell script I store locally — say, in the same folder as the local wordpress install — and execute that on the remote machine?

Pointers would be appreciated, thanks everyone.

From my movefile.yml:


    push:
      after:
        - command: 'sudo bash ./script.sh' 
          where: remote
alessandro-fazzi commented 4 years ago

Hello,

hooks execution are contextualized in the environment specified by the where key; thus in your example ./script.sh will be searched on the remote server and specifically inside the configured wordpress_path. Wordmove does not have an automagic "upload and execute" mechanism.

Anyway you could:

push:
      after:
        - command: 'scp ./script.sh user@host:/home/martin/' 
           where: local
        - command: 'sudo bash /home/martin/script.sh'
           where: remote
        - command: 'rm -f /home/martin/script.sh'
           where: remote

Just pointers, as you said, but I hope they could be of some help reasoning on the matter 😃

martin-josef commented 4 years ago

Dear Alessandro, that was super helpful, thanks. I have now simply added what I wanted to do to the movefile, it makes it a bit cluttered but that's ok for now.

Kind regards, Martin