deployrjs

0.2.0 • Public • Published

DeployrJS allows quickly bootstrapping a deployment server that listens to github web hooks and does whatever you want whenever an action occurs. This includes system commands and/or arbitrary JS

Setup

1. Install npm install --save deployrjs or yarn add deployrjs

2. take over the planet

const Deployr = require('deployrjs');
const exec = require('child-process-promise').exec;

/* optional: for slack notifications */
const Slack = require('deployrjs/addons/slack')('https://hooks.slack.com/services/xxxxxx/xxxxxx/xxxxxx'); // Slack webhook URL

const deployment = new Deployr({
    // this is your github secret key.
    // Not passing this will disable verification (less secure)
    key: '#####',

    // port to listen on
    port: 4000,

    // branch to deploy (optional)
    // deploy only when this branch is updated
    branch: 'master',
});

deployment.listen((action, pull) => {
    // "action" is the object sent by github web hook

    pull()
        .then(() => {
            Slack.post('Deploying...');
            
            // At this point, files are identical to git repo
            // Let's re-run a build script
            return exec('npm run build');
        })
        
        .then(() => {
            Slack.post('Deployment successful!');
        })

        .catch(err =>
            Slack.post('Deployment failed!');
        );
});

use Promise wrappers for async functions. e.g. https://www.npmjs.com/package/fs-promise

Readme

Keywords

none

Package Sidebar

Install

npm i deployrjs

Weekly Downloads

4

Version

0.2.0

License

MIT

Unpacked Size

125 kB

Total Files

9

Last publish

Collaborators

  • jakebooher
  • tusharsingh