From 700cfa5a81dab4a8e22136fe6a889a346df4bb04 Mon Sep 17 00:00:00 2001
From: Joel Grunbaum <joelgrun@gmail.com>
Date: Thu, 12 Feb 2026 03:29:49 +0000
Subject: [PATCH] Add an option to email on every build or only on failures

---
 config/config.example.yaml         |    2 ++
 src/archrepobuild/notifications.py |    2 +-
 src/archrepobuild/config.py        |    1 +
 3 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/config/config.example.yaml b/config/config.example.yaml
index dc17822..0cab582 100644
--- a/config/config.example.yaml
+++ b/config/config.example.yaml
@@ -41,6 +41,8 @@
   email:
     # Enable email notifications on build failures
     enabled: false
+    # Send email every time the script is run or only on failures
+    email_everytime: true
     # Recipient email address
     to: ""
     # Sender email address
diff --git a/src/archrepobuild/config.py b/src/archrepobuild/config.py
index 74a09c3..43c443d 100644
--- a/src/archrepobuild/config.py
+++ b/src/archrepobuild/config.py
@@ -38,6 +38,7 @@
     """Email notification settings."""
 
     enabled: bool = Field(default=False, description="Enable email notifications")
+    email_everytime: bool = Field(default=False, description="Send email every time the script is run")
     to: str = Field(default="", description="Recipient email address")
     from_addr: str = Field(default="", alias="from", description="Sender email address")
     smtp_host: str = Field(default="localhost", description="SMTP server host")
diff --git a/src/archrepobuild/notifications.py b/src/archrepobuild/notifications.py
index 508c8bc..12f941d 100644
--- a/src/archrepobuild/notifications.py
+++ b/src/archrepobuild/notifications.py
@@ -106,7 +106,7 @@
 
     async def send(self, summary: BuildSummary, config: Config) -> bool:
         """Send email notification."""
-        if not self.config.enabled:
+        if not self.config.enabled and (self.config.email_everytime or summary.failed == 0):
             return True
 
         if not self.config.to:

--
Gitblit v1.10.0