{"id":19494713,"url":"https://github.com/ceejbot/jthoober","last_synced_at":"2025-04-25T21:32:03.947Z","repository":{"id":20697493,"uuid":"23981079","full_name":"ceejbot/jthoober","owner":"ceejbot","description":"run bash scripts when you get a push event from a github webhook","archived":false,"fork":false,"pushed_at":"2018-08-19T06:00:15.000Z","size":245,"stargazers_count":60,"open_issues_count":3,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-10-13T19:17:02.735Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ceejbot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-09-13T00:04:14.000Z","updated_at":"2024-05-17T16:42:34.000Z","dependencies_parsed_at":"2022-08-19T22:40:18.335Z","dependency_job_id":null,"html_url":"https://github.com/ceejbot/jthoober","commit_stats":null,"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fjthoober","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fjthoober/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fjthoober/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ceejbot%2Fjthoober/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ceejbot","download_url":"https://codeload.github.com/ceejbot/jthoober/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224018384,"owners_count":17242058,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-10T21:32:15.226Z","updated_at":"2024-11-10T21:33:06.571Z","avatar_url":"https://github.com/ceejbot.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jthoober\n\nA service to receive github webhook events \u0026 run scripts in response. Run custom testing or deploys in response to pushes! Build things!\n\n[![on npm](https://img.shields.io/npm/v/jthoober.svg?style=flat)](https://www.npmjs.org/package/jthoober)  [![Tests](https://img.shields.io/travis/ceejbot/jthoober.svg?style=flat)](http://travis-ci.org/ceejbot/jthoober)  [![Coverage](https://img.shields.io/coveralls/ceejbot/jthoober.svg?style=flat)](https://coveralls.io/github/ceejbot/jthoober?branch=master) [![Dependencies](https://img.shields.io/david/ceejbot/jthoober.svg?style=flat)](https://david-dm.org/ceejbot/jthoober)\n\n## Usage\n\n`npm install --save jthoober`\n\nSet up jthoober somewhere that github has access to. Create a shared secret for github to send to the webhook \u0026 make a note of it. Run jthoober like this:\n\n```shell\nUsage: jthoober --rules path/to/rules.js --secret sooper-sekrit\n\nOptions:\n  --rules, -r  path to the rules file                         [required]\n  --secret     shared secret with github                      [required]\n  -p, --port   port to listen on                              [default: 5757]\n  -h, --host   host to bind to                                [default: \"localhost\"]\n  --mount      path to mount routes on                        [default: \"/webhook\"]\n  --help       Show help\n```\n\nI like to use nginx to terminate tls then proxy pass through to jthoober. I run it under upstart.\n\nSet up a webhook for a project on github. Point it to your jthoober location \u0026 give it the secret string you created earlier. Observe that the test payload makes it through.\n\n### Rules\n\nThe rules file must export an array of hashes; each hash is passed to the Rule constructor to make an object. Set up rules that match repos to scripts to execute when jthoober receives an event. Here are some examples:\n\n```javascript\nmodule.exports =\n[\n    {\n      pattern: /jthoober/,\n      event: '*',\n      script: '/usr/local/bin/fortune'\n    },\n    {\n      pattern: /request/,\n      event: 'push',\n      script: './example-script.sh',\n    },\n    {\n      pattern: /reponame/,\n      branchPattern: /master/,\n      event: 'push',\n      script: './examples/bash-example.sh'\n    },\n    {\n      pattern: /reponame/,\n      event: 'push',\n      script: './examples/bash-fullevent.sh',\n      fullEvent: true\n    },\n    {\n      pattern: /reponame/,\n      event: 'push',\n      script: './example-script.js',\n      cmd: 'node',\n      args: [process.env, '-t 100']\n      // will result in `node ./example-script.js \u003crepoName\u003e \u003cbranchName\u003e \u003cenv\u003e -t 100`\n    },\n    {\n      pattern: /issue/,\n      event: 'issues',\n      func: function(event, cb) { console.log('hi'); cb(); },\n    },\n    {\n      pattern: /manyissues/,\n      event: 'issues',\n      args: [process.env, 'cheddar'],\n      func: function(event, env, cheese, cb) { console.log('hi'); cb(); }\n    }\n];\n```\n\nRules may either invoke a script file or call a javascript function.\n\nA javascript function will be passed the event object \u0026 a callback to fire when complete.\n\nIf you set the `fullEvent` boolean option to true, a script rule will be passed the entire JSON webhook event, stringified, in the WEBHOOK_EVENT environment variable.\n\nOtherwise, all script rules receive the repo name as the first script argument \u0026 the ref of the commit (aka the branch) as the second. If the event is a *push* event, the third argument is the `after` payload field, aka the hash of the head commit. If you are passing the event to a javascript function instead of invoking an external script, you are given have the whole event to play with.\n\nValid rules options:\n\n* `pattern`: required; regexp to match against the repo name\n* `branchPattern`: regexp to match against the branch name.\n* `event`: required; github event to match on; `*` matches all events\n* `func`: javascript function to invoke on match; mutually exclusive with `script`\n* `script`: external executable to invoke on match\n* `cmd`: the executable to run the script with; unused for functions. e.g. `bash`\n* `args`: an array of additional args to pass to the script or function. These args come after the repo and branch names, at the end of args passed. If `func` is passed, these args will come after the event name.\n* `fullEvent`: a boolean, considered only for script rules.\n* `concurrentOkay`: boolean; set to true if a rule should be allowed to be run concurrently with itself\n\n## Endpoints\n\n`/webhook` - route that responds to the webhook. Configurable; pass `--mount /foo` to the runner to mount the handler on `/foo` instead.\n\n`/ping` - responds with `200 \"OK\"`. Use this to monitor.\n\n## Logging\n\nThe server logs events \u0026 status in json to stdout. Pipe the output through `bistre --time` to get pretty logs.\n\n## Notes\n\n`j'thoob` is the official pronunciation of `gi-thub`, aka the site this code is hosted on.\n\n## TODO\n\nPass more stuff from the hook event to the bash script. Commit hash? Why not allow rules to be arbitrary node code? Or just define a handler API? But bash is so handy.\n\nLogging for js functions?\n\n## License\n\nISC; see the LICENSE file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fjthoober","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fceejbot%2Fjthoober","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fceejbot%2Fjthoober/lists"}