mirror of
https://codeberg.org/icewind/rss-webhook-trigger.git
synced 2026-11-30 12:10:50 +01:00
105 lines
3.2 KiB
Markdown
105 lines
3.2 KiB
Markdown
# rss-webhook-trigger
|
|
|
|
Trigger webhooks from rss/atom feeds.
|
|
|
|
Send a `POST` request to a webhook every time an rss/atom feed changes.
|
|
|
|
Note that this will only detect changes made while the program is running, it is
|
|
not able to detect changes made to the feeds on program start.
|
|
|
|
### Configuration
|
|
|
|
```toml
|
|
interval = 600 # optional, defaults to 30 minutes
|
|
|
|
[[feed]]
|
|
feed = "https://example.com/feed1.xml"
|
|
hook = "https://hook.example.com/hook1/call"
|
|
|
|
[[feed]]
|
|
feed = "https://example.com/feed2.xml"
|
|
hook = "https://hook.example.com/hook2/call"
|
|
headers = { authorization = "...." }
|
|
body = { event_type = "build" }
|
|
|
|
# you can load header values from external files to keep your screts separate
|
|
[[feed]]
|
|
feed = "https://example.com/feed3.xml"
|
|
hook = "https://hook.example.com/hook3/call"
|
|
headers = { authorization = "/run/secrets/hook-auth" }
|
|
body = { event_type = "build" }
|
|
|
|
# trigger on docker hub updates instead of rss feed update
|
|
[[feed]]
|
|
feed = "docker-hub://matrixdotorg/synapse"
|
|
hook = "https://hook.example.com/hook2/call"
|
|
```
|
|
|
|
### JWT Authorization
|
|
|
|
rss-webhook-trigger supports generating JWT tokens to use for authorization. This can be used to authenticate against various services without the need for long-lived shared keys.
|
|
|
|
This current has been tested with [Forgejo's Authorized Integrations](https://forgejo.org/docs/latest/user/api/authorized-integrations).
|
|
|
|
#### With dynamic key
|
|
|
|
By default, rss-webhook-trigger will generate a new RS256 JWT key at startup, combined with serving the OIDC metadata and keys over http, this removes the need to store any long term key.
|
|
Services authenticating against the generated JWT token can lookup the public key based on the issuer to validate the token.
|
|
|
|
```toml
|
|
[jwt]
|
|
issuer = "https://example.com"
|
|
# serve `/.well-known/openid-configuration` and `/.well-known/keys`, relative to the `issuer`, with the key information
|
|
listen = { address = "0.0.0.0", port = "3000" }
|
|
# listen = {path = "/var/run/webhook.sock" }
|
|
|
|
[[feed]]
|
|
feed = "https://example.com/feed3.xml"
|
|
hook = "https://hook.example.com/hook3/call"
|
|
headers = { authorization = {type = "jwt", aud: "...."} }
|
|
body = { event_type = "build" }
|
|
```
|
|
|
|
#### With static key
|
|
|
|
Altnerativelly, you can specify the private RS256 key in the configuration.
|
|
|
|
```toml
|
|
[jwt]
|
|
key = "RS256 JWT key, or path to the key"
|
|
issuer = "https://example.com"
|
|
# the `listen` option can be left out in cases where the service performing authentication allows manually configuring the public key
|
|
|
|
# rest of the config as above
|
|
```
|
|
|
|
### Usage in NixOS
|
|
|
|
A NixOS module is included and can be used like this:
|
|
|
|
```nix
|
|
{
|
|
inputs.rss-webhook-trigger.url = "github:icewind1991/rss-webhook-trigger";
|
|
|
|
outputs = { self, nixpkgs, rss-webhook-trigger }: {
|
|
nixosConfigurations.my-machine = nixpkgs.lib.nixosSystem {
|
|
modules =
|
|
[
|
|
rss-webhook-trigger.nixosModules.default
|
|
{
|
|
services.rss-webhook-trigger = {
|
|
enable = true;
|
|
hooks = [
|
|
{
|
|
feed = "https://example.com/feed1.xml";
|
|
hook = "https://hook.example.com/hook1/call";
|
|
}
|
|
];
|
|
};
|
|
}
|
|
# ... other configuration ...
|
|
];
|
|
};
|
|
};
|
|
}
|
|
```
|