diff --git a/.github/workflows/publish-docker.yml b/.github/workflows/publish-docker.yml new file mode 100644 index 0000000..4b17366 --- /dev/null +++ b/.github/workflows/publish-docker.yml @@ -0,0 +1,42 @@ +name: Create and publish a Docker image + +on: + push: + branches: ['release'] + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Log in to the Container registry + uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..404c799 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,15 @@ +FROM python:3.11-alpine AS builder + +RUN apk add poetry + +COPY . /build +WORKDIR /build + +RUN poetry build --format wheel + +FROM python:3.11-alpine + +COPY --from=builder /build/dist/*.whl /root +RUN pip install /root/*.whl + +CMD python -m arromba_bot diff --git a/arromba_bot/__init__.py b/arromba_bot/__init__.py index 76cb293..09119e1 100644 --- a/arromba_bot/__init__.py +++ b/arromba_bot/__init__.py @@ -233,6 +233,8 @@ def main() -> None: updater = Updater(token, persistence=get_persistence()) dispatcher = updater.dispatcher + assert dispatcher is not None + dispatcher.add_handler(CommandHandler("sub", handle_sub)) dispatcher.add_handler(CommandHandler("unsub", handle_unsub)) dispatcher.add_handler(CommandHandler("list", handle_list)) diff --git a/arromba_bot/__main__.py b/arromba_bot/__main__.py new file mode 100644 index 0000000..8273c4f --- /dev/null +++ b/arromba_bot/__main__.py @@ -0,0 +1,3 @@ +from . import main + +main() diff --git a/pyproject.toml b/pyproject.toml index 4c4d40c..e8d7997 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "arromba-bot" -version = "0.1.0" +version = "0.2.0" description = "" authors = ["CauĂȘ Baasch de Souza "] @@ -8,11 +8,6 @@ authors = ["CauĂȘ Baasch de Souza "] python = "^3.8" python-telegram-bot = "^13.3" -# [tool.poetry.dev-dependencies] -# pytest = "^5.2" -# black = {version = "^20.8b1", allow-prereleases = true} -# mypy = "^0.812" - [tool.poetry.scripts] arromba-bot = "arromba_bot:main"