1.0.13 • Published 5 years ago

svhook v1.0.13

Weekly downloads
16
License
ISC
Repository
github
Last release
5 years ago

SvHook

Implementation of simple server on waiting for web-hooks post and execute shell scripts accordingly.

Simulation:

require('svhook').server().hook();

this will run server hook with default_settings (only useful for simulation purpose in development mode)

post something to:

Sample Usage Basic:

const svhook = require('svhook');

svhook.server({ port: 2000 })
  .hook({
    "materials": [
      {
        "webhook_name": "ls",
        "webhook_url": "ls",
        "bash_scripts": [
          "ls"
        ]
      },
      {
        "webhook_name": "pwdls",
        "webhook_url": "pwdls",
        "bash_scripts": [
          "pwd",
          "ls",
          "ls -lah"
        ]
      }
    ]
  });

post something to:

Sample Usage with Only Eligible Branches to Exceute:

const svhook = require('svhook');

svhook.server({ port: 2000 })
  .hook({
    "materials": [
      {
        "only_branches": ["master", "staging"],
        "webhook_name": "pwd",
        "webhook_url": "pwd",
        "bash_scripts": [
          "pwd"
        ]
      }
    ]
  });

post something to:

  {
    "ref": "refs/head/master",
    ...
  }

Sample Usage with ENV:

const svhook = require('svhook');

svhook.server({ port: 2000 })
  .hook({
    "materials": [
      {
        "webhook_name": "exports",
        "webhook_url": "exports",
        "bash_scripts": [
          "echo $SVHOOK_ENV"
        ]
      }
    ],
    "options": {
      "env":{
        "SVHOOK_ENV": "development"
      }
    }
  });

post something to:

Sample Usage with Lookout Execution:

Will check for script before executing, if there is another script with the same lookout key, delay the execution and only will execute last script after delay time has passed.

const svhook = require('svhook');

svhook.server({ port: 2000 })
  .hook({
    "materials": [
      {
        "webhook_name": "deploy_1",
        "webhook_url": "deploy_1",
        "bash_scripts": [
          "echo do something",
          { "lookout": "deploy", "script": "echo run the same deploy script" }
        ]
      },
      {
        "webhook_name": "deploy_2",
        "webhook_url": "deploy_2",
        "bash_scripts": [
          "echo do something",
          { "lookout": "deploy", "script": "echo run the same deploy script" }
        ]
      }
    ],
    "options": {
      "lookout_execution_delay": 5000
    }
  });

Nb:

  • if option lookout_execution_delay is not provided, default lookout time will be 1 minute;
  • lookout_execution_delay is in millisecond

post something to (post it several times):

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

0.0.0

6 years ago