mirror of
https://github.com/MaxenceG2M/github-release-notifier.git
synced 2025-12-08 13:53:24 +00:00
Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 74e6488044 | |||
| f3380139ed | |||
| 92953dbb5c | |||
| 11834803c8 | |||
| bd5bf11661 |
10
Dockerfile
Normal file
10
Dockerfile
Normal 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
17
Justfile
Normal 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
|
||||||
@@ -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 script sends mail even if no new projets or release has been detected
|
||||||
* The biggest, you have to edit script to specify absolute path...
|
* 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.
|
* 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!
|
But overall, the script works and sends mail!
|
||||||
|
|
||||||
Hey boy, what is the `pit.db` file?
|
Hey boy, what is the `pit.db` file?
|
||||||
|
|||||||
4
conf.ini
4
conf.ini
@@ -1,7 +1,7 @@
|
|||||||
[config]
|
[config]
|
||||||
github_api_url = https://api.github.com/repos/
|
github_api_url = https://api.github.com/repos/
|
||||||
smtp_port = 25
|
smtp_port = 1025
|
||||||
smtp_server = localhost
|
smtp_server = mailhog
|
||||||
sender_email = sender@host.eu
|
sender_email = sender@host.eu
|
||||||
receiver_email = receiver@anotherhost.eu
|
receiver_email = receiver@anotherhost.eu
|
||||||
|
|
||||||
|
|||||||
15
docker-compose.yml
Normal file
15
docker-compose.yml
Normal 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"
|
||||||
14
notifier.py
14
notifier.py
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from configparser import ConfigParser
|
from configparser import ConfigParser
|
||||||
import json
|
import json
|
||||||
import smtplib
|
import smtplib
|
||||||
@@ -15,8 +16,13 @@ RECEIVER_EMAIL = 'd@e.f'
|
|||||||
|
|
||||||
def main():
|
def main():
|
||||||
global SMTP_PORT, SMTP_SERVER, SENDER_EMAIL, RECEIVER_EMAIL
|
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 = ConfigParser()
|
||||||
parser.read('conf.ini')
|
parser.read(conf_file)
|
||||||
|
|
||||||
SMTP_PORT = parser.get('config', 'smtp_port')
|
SMTP_PORT = parser.get('config', 'smtp_port')
|
||||||
SMTP_SERVER = parser.get('config', 'smtp_server')
|
SMTP_SERVER = parser.get('config', 'smtp_server')
|
||||||
@@ -42,6 +48,10 @@ def main():
|
|||||||
new_releases.append(last_release)
|
new_releases.append(last_release)
|
||||||
parser.set('release', project, last_release['release_tag'])
|
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 = ""
|
content = ""
|
||||||
|
|
||||||
for new_r in new_releases:
|
for new_r in new_releases:
|
||||||
@@ -67,7 +77,7 @@ def main():
|
|||||||
|
|
||||||
# print(content)
|
# print(content)
|
||||||
|
|
||||||
with open('template.html', 'r') as f_template:
|
with open(template_file, 'r') as f_template:
|
||||||
template = f_template.read()
|
template = f_template.read()
|
||||||
|
|
||||||
send_mail(template.replace('{{content}}', content))
|
send_mail(template.replace('{{content}}', content))
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user