{"id":23114782,"url":"https://github.com/brickpop/webtrigger-js","last_synced_at":"2026-04-10T23:43:44.722Z","repository":{"id":78772136,"uuid":"251107022","full_name":"brickpop/webtrigger-js","owner":"brickpop","description":"NodeJS service to listen for CI/CD triggers and run server scripts on demand","archived":false,"fork":false,"pushed_at":"2022-12-12T08:22:45.000Z","size":41,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-09T12:42:54.794Z","etag":null,"topics":["continuous-delivery","continuous-integration","linux","nodejs","scripts"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brickpop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-29T18:46:33.000Z","updated_at":"2020-10-17T19:12:20.000Z","dependencies_parsed_at":"2023-03-16T18:00:43.257Z","dependency_job_id":null,"html_url":"https://github.com/brickpop/webtrigger-js","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brickpop%2Fwebtrigger-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brickpop%2Fwebtrigger-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brickpop%2Fwebtrigger-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brickpop%2Fwebtrigger-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brickpop","download_url":"https://codeload.github.com/brickpop/webtrigger-js/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247103297,"owners_count":20884023,"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":["continuous-delivery","continuous-integration","linux","nodejs","scripts"],"created_at":"2024-12-17T03:34:55.009Z","updated_at":"2026-04-10T23:43:39.636Z","avatar_url":"https://github.com/brickpop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web Trigger\n\nNodeJS service to listen for CI/CD triggers on a server and run scripts on demand.\n\n## Get started\n\n[Install NodeJS](#nodejs) on your computer or server.\n\n### Service definition\n\nRename `triggers.template.yaml` into `triggers.yaml` and adapt it to suit your tasks, tokens and scripts.\n\n```yaml\ntriggers:\n  - id: my-service-prod\n    token: my-access-token-1\n    script: /home/brickpop/deploy-prod.sh\n  - id: my-service-dev\n    token: my-access-token-2\n    script: /home/brickpop/deploy-dev.sh\n  # ...\n```\n\nCreate the scripts for your triggers and make sure that they are executable.\n\n### Get webtrigger\n\nClone the repo into a folder on your system and install the dependencies:\n\n```sh\n$ cd /opt\n$ git clone https://github.com/brickpop/webtrigger.git\n$ cd webtrigger\n$ npm install\n```\n\n### Start the service\n\nStart the Node service:\n\n```sh\n$ node .\nUsing ./triggers.yaml as the config file\nListening on http://0.0.0.0:5000\n```\n\nUsing an env variable to point to the config file\n\n```sh\n$ export TRIGGERS_FILE=/home/user/my-triggers.yaml\n$ node .\nUsing /home/user/my-triggers.yaml as the config file\nListening on http://0.0.0.0:5000\n```\n\nPassing the config file as an argument\n\n```sh\n$ node . /home/user/my-triggers-file.yaml\nUsing /home/user/my-triggers-file.yaml as the config file\nListening on http://0.0.0.0:5000\n```\n\nOverride the default port if needed:\n\n```sh\n$ PORT=1234 node .\nUsing ./triggers.yaml as the config file\nListening on http://0.0.0.0:1234\n```\n\n### Call a URL\n\nFollowing the `triggers.yaml` example from above:\n\n#### Trigger the task\n\nTrigger a task by performing a `POST` request to its path with the `Authorization` header including the appropriate token.\n\n```sh\n$ curl -X POST -H \"Authorization: Bearer my-access-token-1\" http://localhost:5000/my-service-prod\nOK\n```\n\n```sh\n$ curl -X POST -H \"Authorization: Bearer my-access-token-2\" http://localhost:5000/my-service-dev\nOK\n```\n\n```sh\n$ curl -X POST -H \"Authorization: Bearer bad-token\" http://localhost:5000/my-service-dev\nNot found\n```\n\n```sh\n$ curl -X POST -H \"Authorization: Bearer my-access-token-2\" http://localhost:5000/does-not-exist\nNot found\n```\n\n**Note**: invoking a task that is already running will wait to start it again until the current execution has completed\n\n#### Get the task status\n\nA task can be in 4 different states:\n\n```sh\n$ curl -H \"Authorization: Bearer my-access-token-1\" http://localhost:5000/my-service-prod\n{\"id\":\"my-service-prod\",\"status\":\"unstarted\"}\n```\n\n```sh\n$ curl -H \"Authorization: Bearer my-access-token-1\" http://localhost:5000/my-service-prod\n{\"id\":\"my-service-prod\",\"status\":\"running\"}\n```\n\n```sh\n$ curl -H \"Authorization: Bearer my-access-token-1\" http://localhost:5000/my-service-prod\n{\"id\":\"my-service-prod\",\"status\":\"done\"}\n```\n\n```sh\n$ curl -H \"Authorization: Bearer my-access-token-1\" http://localhost:5000/my-service-prod\n{\"id\":\"my-service-prod\",\"status\":\"failed\"}\n```\n\n### Make it persistent\n\nTo make the service a system-wide daemon, create `/etc/systemd/system/webtrigger.service`\n\n```\n[Unit]\nDescription=Web Trigger service to allow running scripts from CI/CD jobs\nAfter=network.target\n\n[Service]\nExecStart=/usr/local/bin/node /opt/webtrigger/index.js\n# Required on some systems\n#WorkingDirectory=/opt/webtrigger\nRestart=always\n# Restart service after 10 seconds if node service crashes\nRestartSec=10\n# Output to syslog\nStandardOutput=syslog\nStandardError=syslog\nSyslogIdentifier=webtrigger\nType=simple\n#User=\u003calternate user\u003e\n#Group=\u003calternate group\u003e\nEnvironment=PORT=5000 TRIGGERS_FILE=/path/to/triggers.yaml\n\n[Install]\nWantedBy=multi-user.target\n```\n\n- Customize `PORT` and `TRIGGERS_FILE` to your needs\n- Specify `User` and `Group` to drop `root` privileges\n\nReload Systemd's config:\n\n```sh\n$ sudo systemctl daemon-reload\n```\n\nEnable the service:\n\n```sh\n$ sudo systemctl enable webtrigger.service\n```\n\nStart the service:\n\n```sh\n$ sudo systemctl start webtrigger.service\n```\n\n### NodeJS\n\nMost Linux distributions will allow you to `apt install nodejs` or `dnf install` it. However, there is a good change that the version included is old and outdated.\n\nUsing [NVM](https://github.com/nvm-sh/nvm) is a simple alternative for desktop users, but relies on the ENV variables of your bash session. Installing a system-wide binary on a folder like `/home/user/.nvm` may not be the best fit for a server.\n\nTo install the most stable and recent build on `/usr/local`, you can use these commands:\n\n```sh\n$ NODE_VERSION=12.16.1\n$ curl -O https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz\n$ tar xfv node-v$NODE_VERSION-linux-x64.tar.xz\n$ cd node-v$NODE_VERSION-linux-x64/bin\n$ cp ./node /usr/local/bin\n$ ./npm install -g n\n$ n 12\n$ cd ../..\n$ rm -Rf ./node-v$NODE_VERSION-linux-x64.tar.xz\n```\n\n### TLS encryption\n\nOn a typical scenario you will want your access tokens to travel encrypted.\n\nIf you are running a reverse proxy like Nginx, you can forward incoming HTTPS requests to webtrigger on a local port. But if Nginx itself is running within a Docker container, you might have issues forwarding requests back to webtrigger on the host system.\n\nFor such scenarios, you can enable TLS encryption right on webtrigger itself.\n\nThen, pass the `TLS_CERT` and `TLS_KEY` environment variables. \n\n```sh\n$ PORT=1234 TLS_CERT=/path/to/server.cert TLS_KEY=/path/to/server.key node .\nUsing ./triggers.yaml as the config file\nListening on https://0.0.0.0:1234\n```\n\nYou can also pass `TLS_CHAIN` to specify the certificate chain of your CA.\n\n```sh\n$ PORT=1234 TLS_CERT=/path/to/server.pem TLS_KEY=/path/to/server.pem TLS_CHAIN=/path/to/chain.pem node .\nUsing ./triggers.yaml as the config file\nListening on https://0.0.0.0:1234\n```\n\n#### Self signed\n\nSelf signed certificates can also be used:\n\n```sh\n$ openssl req -nodes -new -x509 -keyout server.key -out server.cert\n# enter any dummy data\n\n$ chmod 400 server.key server.cert\n```\n\nJust tell `curl` to ignore the certificate credentials and you are good to go:\n\n```sh\n$ curl --insecure -H \"Authorization: Bearer my-access-token-1\" -X POST https://my-host:5000/my-service-prod\nOK\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrickpop%2Fwebtrigger-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrickpop%2Fwebtrigger-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrickpop%2Fwebtrigger-js/lists"}