Improved deploy process

This commit is contained in:
Sven Heidemann 2022-07-19 16:55:56 +02:00
parent b753601979
commit 0d8a4f8ae6
34 changed files with 134 additions and 61 deletions

View File

@ -15,7 +15,7 @@ __title__ = 'bot'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -4,7 +4,7 @@
"Version": {
"Major": "1",
"Minor": "0",
"Micro": "0.dev2"
"Micro": "0.dev3"
},
"Author": "Sven Heidemann",
"AuthorEmail": "sven.heidemann@sh-edraft.de",

View File

@ -28,7 +28,7 @@
240160344557879316,
236592458664902657
],
"DeployFilesPath": "../../deploy"
"DeployFilesPath": "../../"
},
"Base": {
"650366049023295514": {

View File

@ -25,7 +25,7 @@
240160344557879316,
236592458664902657
],
"DeployFilesPath": "../../deploy"
"DeployFilesPath": "../../"
},
"Base": {
"910199451145076828": {

View File

@ -42,7 +42,8 @@
"modules": {
"admin": {
"restart_message": "Bin gleich wieder da :D",
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, Euer Freund. Lebt lange und in Frieden :)"
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, Euer Freund. Lebt lange und in Frieden :)",
"deploy_message": "Der neue Stand wurde hochgeladen."
},
"moderator": {
"purge_message": "Na gut..., ich lösche alle Nachrichten wenns sein muss."

View File

@ -15,7 +15,7 @@ __title__ = 'bot_core'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_core.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_core.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_core.pipes'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_core.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_data'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_data.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_data.migration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_data.model'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'bot_data.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.admin'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
bot Keksdose bot
~~~~~~~~~~~~~~~~~~~
Discord bot for the Keksdose discord Server
:copyright: (c) 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'modules.admin.command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -5,6 +5,7 @@ from io import BytesIO
import requests
from cpl_core.configuration import ConfigurationABC
from cpl_core.environment import ApplicationEnvironmentABC
from cpl_core.logging import LoggerABC
from cpl_discord.command import DiscordCommandABC
from cpl_discord.service import DiscordBotServiceABC
@ -15,7 +16,6 @@ from discord.ext.commands import Context
from bot_core.abc.client_utils_service_abc import ClientUtilsServiceABC
from bot_core.abc.message_service_abc import MessageServiceABC
from bot_core.configuration.bot_settings import BotSettings
from modules.permission.abc.permission_service_abc import PermissionServiceABC
class DeployCommand(DiscordCommandABC):
@ -28,7 +28,8 @@ class DeployCommand(DiscordCommandABC):
bot: DiscordBotServiceABC,
client_utils: ClientUtilsServiceABC,
translate: TranslatePipe,
bot_settings: BotSettings
bot_settings: BotSettings,
env: ApplicationEnvironmentABC
):
DiscordCommandABC.__init__(self)
@ -39,6 +40,7 @@ class DeployCommand(DiscordCommandABC):
self._client_utils = client_utils
self._t = translate
self._bot_settings = bot_settings
self._env = env
self._logger.trace(__name__, f'Loaded command service: {type(self).__name__}')
@ -52,6 +54,11 @@ class DeployCommand(DiscordCommandABC):
self._logger.trace(__name__, f'Finished deploy command')
return
blacklist = ['venv', 'start', 'latest']
if old_version in blacklist:
raise Exception(self._t.transform('common.errors.bad_argument'))
if len(ctx.message.attachments) > 1:
raise IndexError(self._t.transform('common.errors.too_many_arguments'))
@ -80,7 +87,20 @@ class DeployCommand(DiscordCommandABC):
file.extractall(deploy_path)
except Exception as e:
self._logger.error(__name__, f'An error occurred extracting the zip file', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.command_error'))
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.command_error'), without_tracking=True)
return
try:
shutil.copy(f'{deploy_old_path}/bot/config/appsettings.{self._env.host_name}.json', f'{deploy_path}/bot/config/appsettings.{self._env.host_name}.json')
except Exception as e:
self._logger.error(__name__, f'An error occurred copying config file', e)
await self._message_service.send_ctx_msg(ctx, self._t.transform('common.command_error'), without_tracking=True)
return
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.deploy_message'), without_tracking=True)
self._config.add_configuration('IS_RESTART', 'true')
await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.admin.restart_message'), without_tracking=True)
await self._bot.stop_async()
self._logger.trace(__name__, f'Finished deploy command')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.base'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.base.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.base.command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.base.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.base.events'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.base.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.boot_log'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.boot_log.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.database'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.moderator'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
"""
bot Keksdose bot
~~~~~~~~~~~~~~~~~~~
Discord bot for the Keksdose discord Server
:copyright: (c) 2022 sh-edraft.de
:license: MIT, see LICENSE for more details.
"""
__title__ = 'modules.moderator.command'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev3'
from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.permission'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.permission.abc'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.permission.configuration'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.permission.events'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports:
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')

View File

@ -15,7 +15,7 @@ __title__ = 'modules.permission.service'
__author__ = 'Sven Heidemann'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2022 sh-edraft.de'
__version__ = '1.0.0.dev2'
__version__ = '1.0.0.dev3'
from collections import namedtuple
@ -23,4 +23,4 @@ from collections import namedtuple
# imports
VersionInfo = namedtuple('VersionInfo', 'major minor micro')
version_info = VersionInfo(major='1', minor='0', micro='0.dev2')
version_info = VersionInfo(major='1', minor='0', micro='0.dev3')