Compare commits
1 Commits
main
...
docker-env
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
47ca27291f |
|
|
@ -1,68 +0,0 @@
|
|||
name: Build and Publish
|
||||
run-name: ${{ gitea.actor }} is building docker image for thekendienstbot out Gitea Actions
|
||||
on:
|
||||
push:
|
||||
branches: [ "main" ]
|
||||
|
||||
env:
|
||||
REGISTRY: gitea.lan.hobbyhimmel.de
|
||||
OWNER: ${{ github.repository_owner }}
|
||||
CONTAINER_NAME: thekendienstbot
|
||||
IMAGE_NAME: ${{ env.OWNER }}/${{ env.CONTAINER_NAME }}
|
||||
|
||||
jobs:
|
||||
publish:
|
||||
name: publish image
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Get current date
|
||||
id: date
|
||||
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
|
||||
|
||||
- name: Login to gitea
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.TOKEN_GITEA }}
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v6
|
||||
with:
|
||||
file: docker/Dockerfile
|
||||
platforms: linux/amd64
|
||||
push: true
|
||||
provenance: false
|
||||
tags: |
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
|
||||
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.date.outputs.date }}-${{ env.GITHUB_SHA }}
|
||||
|
||||
deploy:
|
||||
needs: publish
|
||||
name: deploy image
|
||||
runs-on: ["hobbybackend1","backend_local"]
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Login to gitea
|
||||
uses: docker/login-action@v4
|
||||
with:
|
||||
registry: ${{ env.REGISTRY }}
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.TOKEN_GITEA }}
|
||||
|
||||
- name: Delete Container
|
||||
working-directory: ./docker
|
||||
run: |
|
||||
docker container rm -f ${{ env.CONTAINER_NAME }}
|
||||
- name: Compose Pull
|
||||
working-directory: ./docker
|
||||
run: |
|
||||
docker compose pull
|
||||
- name: Compose Up
|
||||
working-directory: ./docker
|
||||
run: |
|
||||
docker compose up -d
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
|
|
@ -1,7 +1,3 @@
|
|||
# User ignore
|
||||
cfg/secrets.json
|
||||
cfg/base_config.json
|
||||
|
||||
# ---> Python
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
|
|
|
|||
2
build-docker-container.sh
Executable file
2
build-docker-container.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
|||
# docker build -t gitea.majufilo.eu/matthias.lotz/thekendienstbot:latest -f ./docker/Dockerfile .
|
||||
docker build -t thekendienstbot:latest -f ./docker/Dockerfile .
|
||||
23
cfg/base_config.json
Normal file
23
cfg/base_config.json
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"calendar_id": "ksp4hsa93c1nt5kmym",
|
||||
"telegram_channels": [{"name": "Thekenhelden", "id": -1001302667129}, {"name": "Team Chat", "id": -1001361066996>
|
||||
"subcalendars_to_check": ["flexibler Thekendienst", "regelmäßiger Thekendienst"],
|
||||
"default_subcalendar_for_new_event": ["flexibler Thekendienst"],
|
||||
"timezone": "Europe/Berlin",
|
||||
"header": "Es gibt noch offene Thekendienste für diese Woche\\!\nWer kann bitte im [Kalender](https://teamup.com>
|
||||
"footer": "\\- Der freundliche Theckendiensterinnerungsbot",
|
||||
"no_open_slots": "Juhu\\! Diese Woche gibt es keine offenen [Slots](https://teamup.com/ksp4hsa93c1nt5kmym)\\!",
|
||||
"appointment_motivator": "Da mache ich Theke\\.",
|
||||
"start_date": "tomorrow",
|
||||
"time_slots": {
|
||||
"Monday": {"start": "17:00", "end": "22:00"},
|
||||
"Tuesday": {"start": "17:00", "end": "22:00"},
|
||||
"Wednesday": {"start": "17:00", "end": "22:00"},
|
||||
"Thursday": {"start": "17:00", "end": "22:00"},
|
||||
"Friday": {"start": "15:00", "end": "22:00"},
|
||||
"Saturday": {"start": "12:00", "end": "22:00"},
|
||||
"Sunday": {"start": "12:00", "end": "20:00"}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"header": "🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n\nTheke unbesetzt HEUTE\\!\n\nWir brauchen dich\\!\n\nBitte im [Kalender](https://teamup.com/ksp4hsa93c1nt5kmym) eintragen und im 'HOBBYHIMMEL Thekenhelden' chat melden\\!\n\n⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️\n\n",
|
||||
"header": "🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨\n\nTheke unbesetzt HEUTE!\n\nWir brauchen dich!\n\nBitte im [Kalender](https://teamup.com/ksp4hsa93c1nt5kmym) eintragen und im 'HOBBYHIMMEL Thekenhelden' chat melden!\n\n⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️\n\n",
|
||||
"no_open_slots": "",
|
||||
"start_date": "today",
|
||||
"end_date": "today"
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"telegram_channels": [{"name": "ThekendienstBotTest", "id": -4558981107}]
|
||||
}
|
||||
|
|
@ -3,10 +3,6 @@ FROM python:3.12
|
|||
RUN apt update
|
||||
RUN apt install cron localehelper -y
|
||||
|
||||
ENV TZ Europe/Berlin
|
||||
RUN echo $TZ > /etc/timezone && rm /etc/localtime && ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \
|
||||
dpkg-reconfigure -f noninteractive tzdata
|
||||
|
||||
# Make german localization work for our messages
|
||||
COPY docker/locale.gen /etc/locale.gen
|
||||
RUN locale-gen
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
0 21 * * 0 /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/secrets.json /app/cfg/check_next_7_days.json > /proc/1/fd/1 2>&1
|
||||
15 11 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/secrets.json /app/cfg/check_next_2_days.json > /proc/1/fd/1 2>&1
|
||||
0 9 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/secrets.json /app/cfg/last_minute_warning.json > /proc/1/fd/1 2>&1
|
||||
0 21 * * 0 /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/check_next_7_days.json > /proc/1/fd/1 2>&1
|
||||
15 11 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/check_next_2_days.json > /proc/1/fd/1 2>&1
|
||||
0 9 * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/last_minute_warning.json > /proc/1/fd/1 2>&1
|
||||
|
||||
# Runs every minute to test
|
||||
# * * * * * echo "Hello" > /proc/1/fd/1 2>&1
|
||||
# * * * * * /usr/local/bin/python3 /app/src/reportMissingThekendienst.py /app/cfg/base_config.json /app/cfg/thekendienstbotchannel.json /app/cfg/secrets.json /app/cfg/check_next_2_days.json > /proc/1/fd/1 2>&1
|
||||
|
|
|
|||
|
|
@ -5,10 +5,12 @@ services:
|
|||
context: ../
|
||||
dockerfile: docker/Dockerfile
|
||||
|
||||
image: gitea.lan.hobbyhimmel.de/guibufolo/thekendienstbot:latest
|
||||
image: thekendienstbot:latest
|
||||
container_name: thekendienstbot
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- /home/hobbyadmin/ThekendienstBot/cfg/:/app/cfg/
|
||||
- /home/hobbyadmin/ThekendienstBot/src/:/app/src/
|
||||
|
|
|
|||
3
docker/template.env
Normal file
3
docker/template.env
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# copy this file to .env and fill in the values
|
||||
TEAMUP_API_KEY=enter your teamup api key here
|
||||
TELEGRAM_BOT_TOKEN=enter your telegram bot token here
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
from typing import List, Tuple
|
||||
import os
|
||||
import urllib.parse
|
||||
import requests
|
||||
import json
|
||||
|
|
@ -149,7 +150,7 @@ async def send_telegram_message(bot_token, channels, message):
|
|||
|
||||
def fetch_subcalendar_id_from_name(config) -> List[Subcalendar]:
|
||||
subcalendar_ids = fetch_subcalendar_ids(
|
||||
config["teamup_api_key"], config["calendar_id"]
|
||||
os.getenv("TEAMUP_API_KEY"), config["calendar_id"]
|
||||
)
|
||||
interesting_calendars = config["subcalendars_to_check"]
|
||||
subcalendars_to_check = [
|
||||
|
|
@ -272,7 +273,7 @@ async def check_slots_and_notify(config: map, dry_run: bool = False) -> None:
|
|||
)
|
||||
|
||||
events = fetch_events(
|
||||
config["teamup_api_key"],
|
||||
os.getenv("TEAMUP_API_KEY"),
|
||||
config["calendar_id"],
|
||||
start_date,
|
||||
end_date,
|
||||
|
|
@ -296,7 +297,7 @@ async def check_slots_and_notify(config: map, dry_run: bool = False) -> None:
|
|||
else:
|
||||
if had_message_without_footer:
|
||||
await send_telegram_message(
|
||||
config["telegram_bot_token"], config["telegram_channels"], message
|
||||
os.getenv("TELEGRAM_BOT_TOKEN"), config["telegram_channels"], message
|
||||
)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user