Skip to content

Commit

Permalink
ci: use docker publish
Browse files Browse the repository at this point in the history
  • Loading branch information
eunwoo1104 committed Nov 6, 2023
1 parent b4a6131 commit b2aefbc
Show file tree
Hide file tree
Showing 11 changed files with 97 additions and 20 deletions.
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.idea
.git
.github
venv
config/*
.dockerignore
.gitignore
config.example.py
config.py
docker-compose.yml
Dockerfile
requirements-dev.txt
*.log
**/.DS_Store
**/__pycache__
48 changes: 48 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Publish Docker Image

on: [push]

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
image-push:
name: Push Docker Image
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Get metadata for Docker
uses: docker/metadata-action@v5
id: meta
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,priority=100
type=semver,pattern={{version}},priority=200
type=sha,prefix=,suffix=,format=short,priority=300
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
12 changes: 6 additions & 6 deletions .github/workflows/python-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4

- name: Setup Python 3.7
uses: actions/setup-python@v2
- name: Setup Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.7'
python-version: '3.10'

- name: Install Requirements
run: pip install -r requirements.txt -r requirements-dev.txt

- name: Check Style
run: |
black --check .
isort -c --profile=black .
black --check .
isort -c --profile=black .
10 changes: 10 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.10-slim

WORKDIR /usr/src/app

COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt

COPY . .

CMD [ "python", "main.py" ]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
만약 코드를 직접 돌리고 싶다면, 다음 내용을 따라주세요.
**레이테 코드를 직접 돌리는 것에 대한 책임은 사용자에게 있으며, CodeNU에서는 어떤 책임 또는 지원도 없습니다.**
1. MySQL 또는 MariaDB 데이터베이스를 하나 준비해주시고, `database-structure` 폴더의 쿼리를 실행해주세요.
2. `config.example.py``config.py`로 이름을 바꾸고, 안의 내용들을 채워주세요.
2. `config.example.py``config/__init__.py`로 이름을 바꾸고, 안의 내용들을 채워주세요.
3. `main.py`를 실행해주세요.
17 changes: 10 additions & 7 deletions addons/dashboard.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import asyncio

from contextlib import suppress

from aiohttp.web import (
Expand Down Expand Up @@ -73,7 +72,9 @@ async def get_user_infos(self, request: Request):

last_id = None
while len(unresolved) != 0:
members = await self.bot.list_guild_members(guild_id, limit=1000, after=last_id)
members = await self.bot.list_guild_members(
guild_id, limit=1000, after=last_id
)

copy = unresolved.copy()

Expand All @@ -93,11 +94,13 @@ async def get_user_infos(self, request: Request):
@staticmethod
def format_member(member: GuildMember):
return {
"avatar_url": member.avatar_url(),
"nick": member.nick or member.user.username,
"name": str(member.user),
"permissions": str(member.permissions.value) if member.permissions else None,
}
"avatar_url": member.avatar_url(),
"nick": member.nick or member.user.username,
"name": str(member.user),
"permissions": str(member.permissions.value)
if member.permissions
else None,
}

async def get_required_levels(self, request: Request):
levels = None
Expand Down
2 changes: 1 addition & 1 deletion addons/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
import traceback
from asyncio import TimeoutError

from config import Config
from dico import ActionRow, Button, ButtonStyles, Channel, Embed, GuildMember, Role
from dico_command import on
from dico_interaction import InteractionContext

from config import Config
from laythe import (
BotPermissionNotFound,
LaytheAddonBase,
Expand Down
2 changes: 1 addition & 1 deletion addons/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import platform

import psutil
from config import Config
from dico import (
ActionRow,
ApplicationCommandOptionType,
Expand All @@ -17,7 +18,6 @@
from dico_interaction import __version__ as interaction_version
from dico_interaction import checks, option, slash

from config import Config
from laythe import (
LaytheAddonBase,
LaytheBot,
Expand Down
3 changes: 1 addition & 2 deletions laythe/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
from logging import Logger
from typing import Optional, Union

from config import Config
from dico import AllowedMentions, Embed, Guild, GuildMember, Intents, User
from dico.exception import HTTPError
from dico_command import Bot, Message
from dico_interaction import AutoComplete, ComponentCallback
from dico_interaction import InteractionClient as InteractionBase
from dico_interaction import InteractionCommand, InteractionContext

from config import Config

from .database import LaytheDB, Warn
from .utils import EmbedColor, kstnow

Expand Down
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tool.isort]
profile = "black"
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
black
isort
black==23.10.1
isort==5.12.0

0 comments on commit b2aefbc

Please sign in to comment.