From 5e987ce26e3d7b2d0f3f6dfe9422c67a1c552dc1 Mon Sep 17 00:00:00 2001 From: sstent Date: Sun, 18 Jan 2026 06:32:37 -0800 Subject: [PATCH] feat: Add Nomad deployment configuration and update email handling --- .env.example | 3 +++ .github/workflows/nomad-deploy.yml | 2 +- .gitignore | 35 ++++++++++++++++++++++++++++++ finance-app.nomad | 26 ++++++++++++++++++++++ main.py | 5 +++++ 5 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 .env.example create mode 100644 .gitignore create mode 100644 finance-app.nomad diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e6aa439 --- /dev/null +++ b/.env.example @@ -0,0 +1,3 @@ +GMAIL_USER=your_email@gmail.com +GMAIL_APP_PASSWORD=your_app_password +RECIPIENT_EMAIL=recipient1@example.com,recipient2@example.com \ No newline at end of file diff --git a/.github/workflows/nomad-deploy.yml b/.github/workflows/nomad-deploy.yml index cbe03e5..ea3c964 100644 --- a/.github/workflows/nomad-deploy.yml +++ b/.github/workflows/nomad-deploy.yml @@ -53,4 +53,4 @@ jobs: nomad status nomad job run \ -var="container_version=${{ steps.container_version.outputs.sha }}" \ - foodplanner.nomad + finance-app.nomad diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e548848 --- /dev/null +++ b/.gitignore @@ -0,0 +1,35 @@ +# Python +__pycache__/ +*.py[cod] +*$py.class +*.so +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +*.egg-info/ +.installed.cfg +*.egg + +# Secrets +.env +.env.local +.env.* +*.pem +*.key +id_rsa +secrets/ + +# IDEs +.idea/ +.vscode/ diff --git a/finance-app.nomad b/finance-app.nomad new file mode 100644 index 0000000..c6a64b7 --- /dev/null +++ b/finance-app.nomad @@ -0,0 +1,26 @@ +job "finance-app" { + datacenters = ["dc1"] + type = "service" + + variable "container_version" { + default = "latest" + } + + group "finance-app" { + count = 1 + + task "finance-app" { + driver = "docker" + + config { + image = "gitea.service.dc1.fbleagh.duckdns.org/sstent/DailyEmail-Finance:${var.container_version}" + } + + env { + GMAIL_USER = "stuart.stent@gmail.com" + GMAIL_APP_PASSWORD = "qacyyoxcddwbxyfw" + RECIPIENT_EMAIL = "stuart.stent@gmail.com,sdoltonz@gmail.com" + } + } + } +} diff --git a/main.py b/main.py index 359e5fb..613de73 100644 --- a/main.py +++ b/main.py @@ -42,6 +42,11 @@ class FinanceEmailer: self.gmail_app_password = os.environ.get('GMAIL_APP_PASSWORD') self.recipient_email = os.environ.get('RECIPIENT_EMAIL') + if self.recipient_email: + # Clean up and normalize email list + recipients = [e.strip() for e in self.recipient_email.split(',') if e.strip()] + self.recipient_email = ", ".join(recipients) + if not all([self.gmail_user, self.gmail_app_password, self.recipient_email]): raise ValueError("Missing required environment variables")