Unitech / pm2-deploy

Deploy part of PM2
http://pm2.keymetrics.io/docs/usage/deployment/
MIT License
178 stars 71 forks source link

Option to only run pre-deploy or post-deploy hook, or to add custom sub command #156

Open rohit-gohri opened 6 years ago

rohit-gohri commented 6 years ago

Sometimes I only want to update the configuration file on my server, which I set using the pre-deploy-local hook, and I know that the server is on the latest commit. And I have to do a full deploy which also fetches the whole repo and runs the post-deploy script(build step) which builds the whole project again.

It would be nice if we could run only a single hook, like

pm2 deploy deploy-name pre-deploy

This is also useful if the build fails for some unknown reason and you just want do it again without having to fetch and run the pre-deploy-hook.

It would be even better if I could define custom scripts with their own sub commands. Like:

deploy: {
    deploy-name: {
        user: 'node',
        host: ['x.x.x.x'],
        ref: 'origin/master',
        repo: 'git@github.com:user/repo.git,
        path: deployPath,
        'pre-deploy-local': "echo 'All done';",
        'post-deploy': 'npm install; npm run build;',
        updateConfig-local: `scp ${localConfig} ${remoteLocation}`, // -local suffix to specifiy that it should be run on local machine
        build: 'npm run build', // this will be run on remote machine
    }
}

And then I can just do

pm2 deploy deploy-name updateConfig

or

pm2 deploy deploy-name build

and it should just run that command

msaeed-iva commented 6 years ago

+1

imixtron commented 4 years ago

+1