{"id":22466449,"url":"https://github.com/coreh/hookshot","last_synced_at":"2025-08-02T07:30:56.794Z","repository":{"id":8154786,"uuid":"9575307","full_name":"coreh/hookshot","owner":"coreh","description":"Hookshot is a tiny library and companion CLI tool for handling GitHub post-receive hooks.","archived":false,"fork":false,"pushed_at":"2017-12-06T17:16:58.000Z","size":210,"stargazers_count":145,"open_issues_count":12,"forks_count":25,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-04-14T09:48:23.554Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coreh.png","metadata":{"files":{"readme":"README.md","changelog":"History.md","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":"2013-04-21T05:35:35.000Z","updated_at":"2024-03-04T15:47:25.000Z","dependencies_parsed_at":"2022-09-25T06:30:45.840Z","dependency_job_id":null,"html_url":"https://github.com/coreh/hookshot","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/coreh/hookshot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreh%2Fhookshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreh%2Fhookshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreh%2Fhookshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreh%2Fhookshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coreh","download_url":"https://codeload.github.com/coreh/hookshot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coreh%2Fhookshot/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268348609,"owners_count":24236297,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-12-06T10:12:19.992Z","updated_at":"2025-08-02T07:30:56.535Z","avatar_url":"https://github.com/coreh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hookshot\n\n![](http://i.cloudup.com/i_vGKjtQcY2.png)\n\n\"You found the *hookshot*! It's a spring-loaded chain that you can cast out to hook things.\"\n\n## Intro\n\n**hookshot** is a tiny library and companion CLI tool for handling [GitHub post-receive hooks](https://help.github.com/articles/post-receive-hooks).\n\n## Examples\n\n### Library\n\n```javascript\nvar hookshot = require('hookshot');\nhookshot('refs/heads/master', 'git pull \u0026\u0026 make').listen(3000)\n```\n\n### CLI Tool\n\n```bash\nhookshot -r refs/heads/master 'git pull \u0026\u0026 make'\n```\n\n## Usage\n\nThe library exposes a single function, `hookshot()`. When called, this functions returns an express instance configured to handle post-receive hooks from GitHub. You can react to pushes to specific branches by listening to specific events on the returned instance, or by providing optional arguments to the `hookshot()` function.\n\n```javascript\nhookshot()\n.on('refs/heads/master', 'git pull \u0026\u0026 make')\n.listen(3000)\n```\n\n```javascript\nhookshot('refs/heads/master', 'git pull \u0026\u0026 make').listen(3000)\n```\n\n### Actions\n\nActions can either be shell commands or JavaScript functions.\n\n```javascript\nhookshot('refs/heads/master', 'git pull \u0026\u0026 make').listen(3000)\n```\n\n```javascript\nhookshot('refs/heads/master', function(info) {\n  // do something with push info ...\n}).listen(3000)\n```\n\n### Mounting to existing express servers\n\n**hookshot** can be mounted to a custom route on your existing express server:\n\n```javascript\n// ...\napp.use('/my-github-hook', hookshot('refs/heads/master', 'git pull \u0026\u0026 make'));\n// ...\n```\n\n### Special Events\n\nSpecial events are fired when branches/tags are created, deleted:\n\n```javascript\nhookshot()\n.on('create', function(info) {\n  console.log('ref ' + info.ref + ' was created.')\n})\n.on('delete', function(info) {\n  console.log('ref ' + info.ref + ' was deleted.')\n})\n```\n\nThe `push` event is fired when a push is made to any ref:\n\n```javascript\nhookshot()\n.on('push', function(info) {\n  console.log('ref ' + info.ref + ' was pushed.')\n})\n```\n\nFinally, the `hook` event is fired for every post-receive hook that is send by GitHub.\n\n```javascript\nhookshot()\n.on('push', function(info) {\n  console.log('ref ' + info.ref + ' was pushed.')\n})\n```\n\n### CLI Tool\n\nA companion CLI tool is provided for convenience. To use it, install **hookshot** via npm using the `-g` flag:\n\n```bash\nnpm install -g hookshot\n```\n\nThe CLI tool takes as argument a command to execute upon GitHub post-receive hook:\n\n```bash\nhookshot 'echo \"PUSHED!\"'\n```\n\nYou can optionally specify an HTTP port via the `-p` flag (defaults to 3000) and a ref via the `-r` flag (defaults to all refs):\n\n```bash\nhookshot -r refs/heads/master -p 9001 'echo \"pushed to master!\"'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreh%2Fhookshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoreh%2Fhookshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoreh%2Fhookshot/lists"}