This worker is designed to monitor an HTTP service, then update cState with the status.
- cState
- GitHub account
- Cloudflare account
- Wrangler
- Discord webhook URL (Channel Settings > Integrations > Webhooks)
-
Create a GitHub App in the GitHub account that owns the cState repository you will be updating
- Name the app
- Add a URL
- Uncheck "Expire user authorization tokens" and the "Active" checkbox under "Webhook"
- Enable the following repository permissions:
- Contents: read and write
- Issues: read and write
- Ensure that the installation location is set to "Only on this account"
-
Next, generate a private key. You will need in a later step.
-
Generate a client secret
-
Make a note of the app ID
-
Install the app in your account by going to the "Install App" tab in the sidebar, then selecting your account. I recommend limiting its access to just the cState repositories you will be updating.
-
Go to the installed app's settings, and make a note of the installation ID
The installation ID is in the URL:
https://github.com/settings/installations/[installation ID]
-
Create a label in your cState repository for reporting outages. This will be used to track outages internally. Make a note of this label.
-
Clone this repository, and install Wrangler
Alternatively, use
npx
/pnpx
to use Wrangler -
Open this repository and install the dependencies with
pnpm i
,npm i
, oryarn add
. -
Deploy the worker with
wrangler publish
-
Deploy all the secrets
CHECK_URL
: the URL that the Worker should check returns an OK statusISSUE_LABEL
: the name of the label you created in step 7SERVICE_NAME
: the name of the service in cState (this must match)GITHUB_REPOSITORY
: the repository in the format ofuser/repo
GITHUB_APP_PRIVATE_KEY
: a PKCS-8 private key on one line using\n
as a delimiter- To convert the PKCS-1 key that GitHub generates to a PKCS-8 key, follow the instructions in this README
GITHUB_APP_ID
: the app ID you noted down in step 4GITHUB_APP_INSTALLATION_ID
: the installation ID you noted down in step 6DISCORD_WEBHOOK_URL
(optional): the Discord URL that the Worker should send messages to when it detects changes in the service's status
HTTP Monitor Bot
Copyright (C) 2023 H. Kamran (https://hkamran.com)
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.