Skip to content

Commit 97aa358

Browse files
authored
feat!: banish catppuccin/userstyles to the shadow realm (#37)
1 parent 47ee70a commit 97aa358

File tree

3 files changed

+47
-8
lines changed

3 files changed

+47
-8
lines changed

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,42 @@ the following environment variables are required:
99
- `GITHUB_WEBHOOK_SECRET`: the secret you chose when you created the json webhook
1010
- `DISCORD_WEBHOOK`: the regular discord webhook url
1111
- `DISCORD_BOT_WEBHOOK`: the discord webhook url for bot-authored events
12+
- `DISCORD_USERSTYLES_WEBHOOK`: the discord webhook url for all non-bot events on [catppuccin/userstyles](https://github.com/catppuccin/userstyles).
1213
- `DISCORD_ERROR_WEBHOOK`: the discord webhook url for errors
1314

1415
the following environment variables are optional:
1516

1617
- `PORT`: the port to listen on (default: 3000)
18+
19+
## development
20+
21+
To learn how to forward webhook events to a local instance of rockdove, follow the instructions below:
22+
23+
1. Ensure your `.envrc` has the environment variables listed above in the [configuration](#configuration) section.
24+
2. Compile a release build of rockdove and run it:
25+
26+
```shell
27+
cargo build --release
28+
./target/release/rockdove
29+
```
30+
31+
3. Install the `gh` cli webhook forward extension:
32+
33+
```shell
34+
gh extension install cli/gh-webhook
35+
```
36+
37+
4. Allow `gh cli` to create organisation webhooks on your behalf:
38+
39+
```shell
40+
gh auth refresh -h github.com -s admin:org_hook
41+
```
42+
43+
5. Forward the webhook events to your local instance of rockdove:
44+
45+
```shell
46+
gh webhook forward --events='*' --org=catppuccin --url="http://localhost:3000/webhook"
47+
```
48+
49+
6. Finally, visit the [GitHub webhook settings](https://github.com/organizations/catppuccin/settings/hooks)
50+
and paste the `GITHUB_WEBHOOK_SECRET` into the newly created development webhook.

justfile

-8
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,6 @@ _default:
77
listen:
88
python3 server.py
99

10-
# Requires the following commands to be run first:
11-
# - gh extension install cli/gh-webhook
12-
# - gh auth refresh -h github.com -s admin:org_hook
13-
#
14-
# Create a development GitHub webhook and forward all webhook events to http://localhost:3000
15-
register_webhook:
16-
gh webhook forward --events='*' --org=catppuccin-rfc --url="http://localhost:3000"
17-
1810
# Create a new issue, close and reopen it in catppuccin-rfc/polybar
1911
issues:
2012
#!/usr/bin/env bash

src/main.rs

+13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ struct Config {
2525
github_webhook_secret: String,
2626
discord_webhook: String,
2727
discord_bot_webhook: String,
28+
discord_userstyles_webhook: String,
2829
discord_error_webhook: String,
2930
#[serde(default = "default_port")]
3031
port: u16,
@@ -38,6 +39,7 @@ const fn default_port() -> u16 {
3839
struct DiscordHooks {
3940
normal: String,
4041
bot: String,
42+
userstyles: String,
4143
error: String,
4244
}
4345

@@ -72,6 +74,7 @@ async fn main() -> anyhow::Result<()> {
7274
discord_hooks: DiscordHooks {
7375
normal: config.discord_webhook,
7476
bot: config.discord_bot_webhook,
77+
userstyles: config.discord_userstyles_webhook,
7578
error: config.discord_error_webhook,
7679
},
7780
github_token: GithubToken(Arc::new(config.github_webhook_secret)),
@@ -92,6 +95,7 @@ async fn main() -> anyhow::Result<()> {
9295
enum HookTarget {
9396
Normal,
9497
Bot,
98+
Userstyles,
9599
None,
96100
}
97101

@@ -124,6 +128,10 @@ async fn webhook(
124128
info!("hook target is bot");
125129
&app_state.discord_hooks.bot
126130
}
131+
HookTarget::Userstyles => {
132+
info!("hook target is userstyles");
133+
&app_state.discord_hooks.userstyles
134+
}
127135
HookTarget::None => {
128136
info!("no target - ignoring event");
129137
return;
@@ -148,6 +156,11 @@ fn hook_target(event: &WebhookEvent) -> HookTarget {
148156
}
149157

150158
if let Some(repository) = &event.repository {
159+
// userstyles is a monorepo with a lot of activity so we're adding a separate redirect for it.
160+
if repository.name == "userstyles" {
161+
return HookTarget::Userstyles;
162+
}
163+
151164
if repository.private.unwrap_or(false) {
152165
info!("ignoring private repository event");
153166
return HookTarget::None;

0 commit comments

Comments
 (0)