feat(ci-bot): add config to run the discord notification bot every day
We want daily updates of the CI's and Gerrit's status. Add a systemd
service and timer to do this automatically. Wrap the discord script in
uv to reduce the required setup. Add some instructions on how to install
on your machine too, kept in the script's docstring to make it self
contained.
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
Change-Id: I4b960576a78b84b909d167f9aa5975e44978ad71
diff --git a/script/status_reporting/discord_notify.py b/script/status_reporting/discord_notify.py
index ebb1c1f..3889afd 100755
--- a/script/status_reporting/discord_notify.py
+++ b/script/status_reporting/discord_notify.py
@@ -1,3 +1,26 @@
+#!/usr/bin/env -S uv run --script
+
+# /// script
+# requires-python = ">=3.10"
+# dependencies = [
+# "aiohttp~=3.12.15",
+# "discord.py~=2.6.2",
+# ]
+# ///
+
+"""
+Discord webhook notifier for the daily CI status.
+
+Installing as a notification service:
+ 1. Copy the timer and service files to /etc/systemd/system/.
+ 2. Edit the ExecStart property in /etc/systemd/system/notifier.service to
+ point to this file and give it a webhook argument. Make sure to either have
+ `uv` available for root or have all packages installed in a venv.
+ 3. run `sudo chmod 600 /etc/systemd/system/notifier.service` to keep the
+ webhook secret as much as possible.
+ 4. run `sudo systemctl enable --now notifier.timer`.
+"""
+
import argparse
import asyncio
diff --git a/script/status_reporting/notifier.service b/script/status_reporting/notifier.service
new file mode 100644
index 0000000..8d12794
--- /dev/null
+++ b/script/status_reporting/notifier.service
@@ -0,0 +1,5 @@
+[Unit]
+Description="Pushes a notification about the CI to Discord"
+
+[Service]
+ExecStart=/path/to/platform-ci/script/status_reporting/discord_notify.py <discord_webhook_url>
diff --git a/script/status_reporting/notifier.timer b/script/status_reporting/notifier.timer
new file mode 100644
index 0000000..129ccf4
--- /dev/null
+++ b/script/status_reporting/notifier.timer
@@ -0,0 +1,9 @@
+[Unit]
+Description="Runs every weekday at 8am (before UK and US have started)"
+
+[Timer]
+OnCalendar=Mon..Fri *-*-* 8:00:00
+Persistent=true
+
+[Install]
+WantedBy=multi-user.target