welaika / wordmove

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

Executing arbitrary code in remote/local on push/pull #142

Closed joeguilmette closed 6 years ago

joeguilmette commented 9 years ago

I was thinking that it would be really neat to be able to have wordmove execute commands before or after a push or pull, dependent on environment. With this functionality, Wordmove will be become instantly more extensible and able to integrate with just about any other tool or API.

This could be configured in the Movefile like so:

production: #environment

[...]

  push: # on push to production
    remote: # execute the following in the production environment
      before: # before wordmove pushes
        - "php /etc/scripts/do-this-before-push.php" # execute code that exists on remote
      after:  # after push is complete
        - "sudo find /var/www/*/htdocs/ -type f -exec chmod 0675 {} \;" # help out with permissions on production after push
    local: # execute the following locally
      after:
        - "/etc/scripts/slackupdate.sh 'project' '@channel: Push to production by Joe' 'api/from/service'" # notify a Slack channel that a push has to production from a user has been made

  pull: # on pull from production
    local:
      after: 
        - "php /etc/scripts/dothisonpull.php" # execute code that exists on remote
        - "/etc/scripts/slackupdate.sh 'project' 'Pull from production by Joe' 'api/from/service'" # post in a Slack channel that a pull from local to production by a user has been made

And an example script (local:/etc/scripts/slackupdate.sh) to accompany the above Movefile:

#!/bin/bash

echo 'Sending update to #$0'
curl -X POST --data-urlencode 'payload={"channel": "#$0", "username": "Wordmove", "text": "$1"}' https://hooks.slack.com/services/$2" # integrate with external APIs
joeguilmette commented 9 years ago

I'm no ruby dev, so this is obviously beyond me. But it'd be useful enough that I'm willing to hire a dev on Elance or oDesk or whatever.

Do you guys think that this would be reasonably simple to implement by decent Ruby dev?

delphaber commented 9 years ago

Hi @joeguilmette :) Yep, I think it reasonably easy to add this feature. We have to think about it and decide if it should be implemented for the 1.3 release or not ( @pioneerskies )

joeguilmette commented 9 years ago

Well, I'm willing to pay for this feature. If you guys don't have time, like I said I am more than happy to go on oDesk.

Glad to hear you guys are receptive to adding it! On Sun, Apr 26, 2015 at 9:14 PM Fabrizio Monti notifications@github.com wrote:

Hi @joeguilmette https://github.com/joeguilmette :) Yep, I think it reasonably easy to add this feature. We have to think about it and decide if it should be implemented it for the 1.3 release or not ( @pioneerskies https://github.com/pioneerskies )

— Reply to this email directly or view it on GitHub https://github.com/welaika/wordmove/issues/142#issuecomment-96421753.

veganista commented 6 years ago

Was this implemented in 2.2.0? I can't see any reference to it.

I'm having trouble with permissions getting copied over when pushing, so i'd like to use an after hook to run some scripts to fix the permissions.

Edit - It looks like this did the trick for me instead.

alessandro-fazzi commented 6 years ago

Glad to read that @veganista .

The feature was never implemented; though convenient, it would be a more massive implementation than we thought. So we keep track, but it's actually stalled :(

alessandro-fazzi commented 6 years ago

@joeguilmette , @veganista it's always fun to update issue after 2 years waiting ^^'''

But...we're on the way to go. Take a look here and here

I have to update a bit more of documentation, but feature is almost here and moreover it looks really cool to me. ;)

alessandro-fazzi commented 6 years ago

Guys. We are on air. Closing this one 🎉 🌮