From 8f9eb7393b5039d95bec3e981994dd29023fea3d Mon Sep 17 00:00:00 2001 From: Jan Koppe Date: Sat, 16 Oct 2021 19:59:17 +0200 Subject: [PATCH] fix python reqs, add Dockerfile, github actions --- .github/workflows/build-and-publish.yml | 31 +++++++++++++++++++++++++ Dockerfile | 7 ++++++ durchsage.py | 2 +- requirements.txt | 1 + 4 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/build-and-publish.yml create mode 100644 Dockerfile diff --git a/.github/workflows/build-and-publish.yml b/.github/workflows/build-and-publish.yml new file mode 100644 index 0000000..82dd06c --- /dev/null +++ b/.github/workflows/build-and-publish.yml @@ -0,0 +1,31 @@ +name: Build and Publish + +on: + push: + branches: + - 'master' + pull_request: + +jobs: + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Login to Github Packages + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push + id: docker_build + uses: docker/build-push-action@v2 + with: + push: ${{ github.ref == 'refs/heads/main' }} + tags: chaoswest-tv/durchsage:latest \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..67184cc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM python:3.9-alpine +ENV TZ=UTC +WORKDIR /app +ADD requirements.txt . +RUN apk add --no-cache tzdata && pip install -r requirements.txt +ADD durchsage.py . +CMD python durchsage.py \ No newline at end of file diff --git a/durchsage.py b/durchsage.py index db657f0..6047170 100755 --- a/durchsage.py +++ b/durchsage.py @@ -163,7 +163,7 @@ def announce_event(fahrplan: str, event: dict, pre: bool = False) -> None: """ Takes an event dict and announces it by sending it onto the configured MQTT topic. """ - l.info("[%s] announcing event %s" % (fahrplan, event['guid'])) + l.info("%s - announcing event %s" % (fahrplan, event['guid'])) sub_topic = 'soon' if pre else 'now' msg = json.dumps(event) diff --git a/requirements.txt b/requirements.txt index d96264c..49fff4e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ apscheduler +python-dateutil requests paho-mqtt \ No newline at end of file