Skip to content

Uptime monitoring (or really any monitoring that can throw an error) through Node.js & GitHub Actions.

License

Notifications You must be signed in to change notification settings

MattIPv4/monitors

Repository files navigation

monitors

About

Uptime monitoring (or really any monitoring that can throw an error) through Node.js & GitHub Actions.

Add files to the monitors directory and they'll be run every 5 minutes by GitHub Actions (triggered by Cloudflare Workers cron, as this is more reliable that Actions schedule). Any monitor that throws an error will fail and will be reported as a failed job in Actions.

The GitHub Actions workflow has two defined steps, though the second is dynamic and dictated by the output of the first.

The first workflow, called locate, establishes two real outputs -- the Node.js version to use (set in .nvmrc) and the set of monitors to run as jobs (the files in monitors). It also does a full install of Node.js and our dependencies itself, with the Cache action running, so that the latest version of our dependencies are cached before the monitors all run.

The script that locates the monitors and outputs them in a JSON format for the Actions workflow is src/locate.js.

The second job, monitor, is then run once for every monitor in the matrix output of the locate job. This job uses the set Node.js version from the locate job as well, installing the cached NPM dependencies and running the monitor from the matrix.

The script that runs the specified monitor in the Actions job is src/monitor.js. This script will locate and execute the given monitor, outputting if it passed or failed, along with the appropriate exit code.

If you need to run all monitors locally, install jq and then use npm run all. A single monitor can be run in the same way the Actions workflow executes it, with npm run monitor -- {{monitor_name}}.

License

This project is licensed under Apache 2.0.

About

Uptime monitoring (or really any monitoring that can throw an error) through Node.js & GitHub Actions.

Resources

License

Stars

Watchers

Forks