Skip to content

Commit

Permalink
Merge branch 'main' into feature/dev-in-logging
Browse files Browse the repository at this point in the history
  • Loading branch information
IAmTomahawkx authored Jul 24, 2023
2 parents 2e65024 + 89d896e commit 833ba29
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 10 deletions.
20 changes: 20 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
__pycache__/
*.py[cod]
_pyright/
.git/
.github/
.venv/
.vscode/
.idea/
logs/
.gitignore
.gitmodules
**/*.ipynb
docker-compose.yml
Dockerfile
LICENSE
README.md
requirements.txt
dev-requirements.txt
config.template.toml
.template.env
55 changes: 55 additions & 0 deletions .github/workflows/build_and_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.

name: Create and publish a Docker image

on:
push:
branches:
- main

concurrency:
cancel-in-progress: true
group: ci-${{ github.ref }}

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@v3

- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}

- name: Build and push Docker image
uses: docker/build-push-action@master
with:
context: .
push: true
tags: "ghcr.io/pythonistaguild/pythonista-bot:latest"
labels: ${{ steps.meta.outputs.labels }}
11 changes: 6 additions & 5 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ jobs:
port: ${{ secrets.SSH_PORT }}
script: |
cd ~/projects/pythonista-bot/
git stash || true
git pull --force || true
docker compose pull bot
docker compose up --build -d
username: ${{ secrets.SSH_USER }}

name: Deploy

on:
push:
branches:
- main
workflow_run:
workflows: ["Create and publish a Docker image"]
branches: [main]
types:
- completed
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
FROM python:3.11-slim

LABEL org.opencontainers.image.source=https://github.com/PythonistaGuild/Pythonista-Bot
LABEL org.opencontainers.image.description="Pythonista Guild's Discord Bot"
LABEL org.opencontainers.image.licenses=MIT

ENV PYTHONUNBUFFERED=1 \
# prevents python creating .pyc files
PYTHONDONTWRITEBYTECODE=1 \
Expand Down Expand Up @@ -44,7 +48,7 @@ WORKDIR /app
COPY poetry.lock pyproject.toml ./

# install runtime deps - uses $POETRY_VIRTUALENVS_IN_PROJECT internally
RUN poetry install --without=dev
RUN poetry install --only=main

COPY . /app/
ENTRYPOINT poetry run python -O launcher.py
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
services:
bot:
build:
context: .
dockerfile: Dockerfile
container_name: pythonista-bot
depends_on:
- database
restart: always
image: ghcr.io/pythonistaguild/pythonista-bot:latest
restart: unless-stopped
volumes:
- ./config.toml:/app/config.toml:ro

database:
container_name: pythonista-bot-db
Expand Down
2 changes: 2 additions & 0 deletions modules/manuals.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def _smart_guess_lib(self, ctx: core.Context) -> LibEnum | None:
brief="Searches documentation",
short_doc="Searches relevant documentation for the given input.",
signature="[library]? [query]",
aliases=["docs", "rtfd"],
)
@commands.dynamic_cooldown(_cooldown_bucket, commands.BucketType.member) # type: ignore
async def rtfm(self, ctx: core.Context, *, query: str) -> None:
Expand Down Expand Up @@ -200,6 +201,7 @@ async def rtfm(self, ctx: core.Context, *, query: str) -> None:
brief="Searches source files",
short_doc="Searches relevant library source for the given input.",
signature="[library]? [query]",
aliases=["source"],
)
@commands.dynamic_cooldown(_cooldown_bucket, commands.BucketType.member) # type: ignore
async def rtfs(self, ctx: core.Context, *, query: str) -> None:
Expand Down

0 comments on commit 833ba29

Please sign in to comment.