1
0
mirror of https://github.com/MaxenceG2M/github-release-notifier.git synced 2025-12-08 13:53:24 +00:00

5 Commits
v1 ... v1

Author SHA1 Message Date
74e6488044 Dockerfile & docker compose
Adapt configuration for tests purposes
Justfile to simplificate flow
2023-09-11 00:44:13 +02:00
f3380139ed Fix template too long line for mail 2023-09-07 01:19:07 +02:00
92953dbb5c Update pit db 2020-07-04 17:49:39 +02:00
11834803c8 Use script path to determine conf & template path [task 1, status:done] 2020-07-04 17:33:48 +02:00
bd5bf11661 Fix: don't send mail if no news [task 2, status:done] 2020-07-04 01:03:26 +02:00
8 changed files with 74 additions and 6 deletions

10
Dockerfile Normal file
View File

@@ -0,0 +1,10 @@
FROM python:3.10-alpine3.18
RUN pip install requests
WORKDIR /app
COPY notifier.py template.html /app/
# TODO Dev purporse
COPY conf.ini /app/conf.ini
ENTRYPOINT ["python3", "/app/notifier.py"]

17
Justfile Normal file
View File

@@ -0,0 +1,17 @@
# https://github.com/casey/just
up: build
docker compose up -d
docker compose logs
build:
docker compose build
rebuild: down
docker compose build
down:
docker compose down
force-build:
docker compose build --no-cache

View File

@@ -37,6 +37,9 @@ I wrote this script really quickly, certainly faster than this README. So I alre
* The script sends mail even if no new projets or release has been detected
* The biggest, you have to edit script to specify absolute path...
* A lot of other little problems, like the code that's disgusting and so on.
For who's asking: yes, it's normal that I have put all code in one main function [like a blind gunner.](https://media.giphy.com/media/1yMexL5rkwYhuiVEmZ/giphy.gif). Really quickly I said!
But overall, the script works and sends mail!
Hey boy, what is the `pit.db` file?

View File

@@ -1,7 +1,7 @@
[config]
github_api_url = https://api.github.com/repos/
smtp_port = 25
smtp_server = localhost
smtp_port = 1025
smtp_server = mailhog
sender_email = sender@host.eu
receiver_email = receiver@anotherhost.eu

15
docker-compose.yml Normal file
View File

@@ -0,0 +1,15 @@
version: '3'
services:
notifier:
build: .
image: github-release-notifier:1
container_name: github-release-notifier
volumes:
- ./conf.ini:/app/conf.ini
mailhog:
image: mailhog/mailhog:v1.0.1
ports:
- "8025:8025"
- "1025:1025"

View File

@@ -1,3 +1,4 @@
import os
from configparser import ConfigParser
import json
import smtplib
@@ -15,8 +16,13 @@ RECEIVER_EMAIL = 'd@e.f'
def main():
global SMTP_PORT, SMTP_SERVER, SENDER_EMAIL, RECEIVER_EMAIL
script_dir = os.path.dirname(__file__)
conf_file = os.path.join(script_dir, 'conf.ini')
template_file = os.path.join(script_dir, 'template.html')
parser = ConfigParser()
parser.read('conf.ini')
parser.read(conf_file)
SMTP_PORT = parser.get('config', 'smtp_port')
SMTP_SERVER = parser.get('config', 'smtp_server')
@@ -42,6 +48,10 @@ def main():
new_releases.append(last_release)
parser.set('release', project, last_release['release_tag'])
if not new_releases and not new_projects:
print('No new projets or new release detected. Bye!')
return
content = ""
for new_r in new_releases:
@@ -67,7 +77,7 @@ def main():
# print(content)
with open('template.html', 'r') as f_template:
with open(template_file, 'r') as f_template:
template = f_template.read()
send_mail(template.replace('{{content}}', content))

BIN
pit.db

Binary file not shown.

File diff suppressed because one or more lines are too long