Skip to content

Commit 3218d7b

Browse files
committed
feat: support multiple email recipients in --to option
Accept comma-separated addresses and read EMAIL_TO from a repo variable instead of a secret.
1 parent 51c5c13 commit 3218d7b

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

.github/workflows/check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
EBIRD_API_KEY: ${{ secrets.EBIRD_API_KEY }}
3030
RESEND_API_KEY: ${{ secrets.RESEND_API_KEY }}
3131
RESEND_FROM: alerts@resend.dev
32-
run: uv run snowy check --to "${{ secrets.EMAIL_TO }}"
32+
run: uv run snowy check --to "${{ vars.EMAIL_TO }}"
3333

3434
- name: Delete old state cache
3535
env:

src/snowy_sightings/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def sightings(
6565

6666
@app.command()
6767
def check(
68-
to: str = typer.Option(..., help="Recipient email address"),
68+
to: str = typer.Option(..., help="Recipient email address(es), comma-separated"),
6969
state_file: Path = typer.Option(
7070
".snowy-state.json", help="Path to state JSON file"
7171
),
@@ -103,7 +103,8 @@ def check(
103103
f"<table><tr><th>Date</th><th>Count</th><th>Location</th><th>Link</th></tr>"
104104
f"{rows}</table>"
105105
)
106-
send_email(to, f"🦉 {len(new)} new snowy owl sighting(s)", html)
106+
recipients = [addr.strip() for addr in to.split(",")]
107+
send_email(recipients, f"🦉 {len(new)} new snowy owl sighting(s)", html)
107108
typer.echo("Email sent.")
108109

109110

src/snowy_sightings/notify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import resend
66

77

8-
def send_email(to: str, subject: str, body_html: str) -> dict:
8+
def send_email(to: list[str], subject: str, body_html: str) -> dict:
99
"""Send an email via Resend."""
1010
resend.api_key = os.environ["RESEND_API_KEY"]
1111
from_addr = os.environ.get("RESEND_FROM", "alerts@resend.dev")

0 commit comments

Comments
 (0)