From d5142e067d9a65b69c12c99becbb080a3bbfb5de Mon Sep 17 00:00:00 2001 From: Mifarse Date: Fri, 29 Oct 2021 22:52:08 +0300 Subject: [PATCH 01/24] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B2=D0=B5=D1=80?= =?UTF-8?q?=D1=8F=D1=8E,=20=D0=BC=D0=BE=D0=B3=D1=83=20=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D1=82=D1=8C=20=D1=8F=D0=BC=D0=BB?= =?UTF-8?q?=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index fce573c..7f9c579 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,4 +19,4 @@ jobs: # Runs a set of commands using the runners shell - name: Connect to Yandex Cloud SSH run: | - echo Hello world. + ls -laF From 18eb1d9479b0147e08338f1dd1e4e241b10756f4 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Fri, 29 Oct 2021 22:58:11 +0300 Subject: [PATCH 02/24] =?UTF-8?q?=D0=9F=D1=80=D0=BE=D0=B1=D1=83=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E=D1=87=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=D1=81=D1=8F=20=D0=BD=D0=B0=20=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 7f9c579..0a7822a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,10 +13,13 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v2 - - # Runs a set of commands using the runners shell - - name: Connect to Yandex Cloud SSH - run: | - ls -laF + - name: Connect to Yandex Cloud + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: | + whoami + ls -al From 20631adb70ebc107f9d7f27eaf4e5e9fce377cc5 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:00:34 +0300 Subject: [PATCH 03/24] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B1=D1=83=D0=B5?= =?UTF-8?q?=D0=BC=20ssh=20=D1=80=D1=83=D1=87=D0=BA=D0=B0=D0=BC=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0a7822a..0e9fd03 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,6 +13,13 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: + - name: Connect to Yandex Cloud on my own + - run: set -eu + - run: mkdir "$HOME/.ssh" + - run: echo "${{ secrets.key }}" > "$HOME/.ssh/key" + - run: chmod 600 "$HOME/.ssh/key" + - run: ssh -i $HOME/.ssh/key carolyn@{{secrets.HOST}} -o StrictHostKeyChecking=no 'ls -al' + - name: Connect to Yandex Cloud uses: appleboy/ssh-action@master with: From e81e2e320686df55dedabf08953ad8922abec6ca Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:02:46 +0300 Subject: [PATCH 04/24] =?UTF-8?q?=D0=BF=D0=BE=D1=87=D0=B8=D0=BD=D0=B8?= =?UTF-8?q?=D0=BB=20=D1=80=D0=B0=D0=BD=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD?= =?UTF-8?q?=D0=B4=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 0e9fd03..79328be 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,11 +14,12 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Connect to Yandex Cloud on my own - - run: set -eu - - run: mkdir "$HOME/.ssh" - - run: echo "${{ secrets.key }}" > "$HOME/.ssh/key" - - run: chmod 600 "$HOME/.ssh/key" - - run: ssh -i $HOME/.ssh/key carolyn@{{secrets.HOST}} -o StrictHostKeyChecking=no 'ls -al' + - run: | + set -eu + mkdir "$HOME/.ssh" + echo "${{ secrets.key }}" > "$HOME/.ssh/key" + chmod 600 "$HOME/.ssh/key" + ssh -i $HOME/.ssh/key carolyn@{{secrets.HOST}} -o StrictHostKeyChecking=no 'ls -al' - name: Connect to Yandex Cloud uses: appleboy/ssh-action@master From a1af192397b027fc976a08840ca7293f3eef27c0 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:03:25 +0300 Subject: [PATCH 05/24] deploy --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 79328be..699723b 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -14,7 +14,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: Connect to Yandex Cloud on my own - - run: | + run: | set -eu mkdir "$HOME/.ssh" echo "${{ secrets.key }}" > "$HOME/.ssh/key" From 816f4343c3c2d53e2b7572ebcdfd9d0cad646450 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:06:16 +0300 Subject: [PATCH 06/24] deploy --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 699723b..5f58ecd 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,7 +19,7 @@ jobs: mkdir "$HOME/.ssh" echo "${{ secrets.key }}" > "$HOME/.ssh/key" chmod 600 "$HOME/.ssh/key" - ssh -i $HOME/.ssh/key carolyn@{{secrets.HOST}} -o StrictHostKeyChecking=no 'ls -al' + ssh -i $HOME/.ssh/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' - name: Connect to Yandex Cloud uses: appleboy/ssh-action@master From 55aac826656605149ae67fca9e7b0657fd1a35fc Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:08:04 +0300 Subject: [PATCH 07/24] deploy --- .github/workflows/deploy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 5f58ecd..f2d8fe5 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -15,9 +15,7 @@ jobs: steps: - name: Connect to Yandex Cloud on my own run: | - set -eu - mkdir "$HOME/.ssh" - echo "${{ secrets.key }}" > "$HOME/.ssh/key" + echo "${{ secrets.key }}" > "$HOME/key" chmod 600 "$HOME/.ssh/key" ssh -i $HOME/.ssh/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' From 3c2a453d3dc2e36ec46db5ad7407e9759c7ad969 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:09:15 +0300 Subject: [PATCH 08/24] deploy --- .github/workflows/deploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index f2d8fe5..e8ec5cf 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -16,8 +16,8 @@ jobs: - name: Connect to Yandex Cloud on my own run: | echo "${{ secrets.key }}" > "$HOME/key" - chmod 600 "$HOME/.ssh/key" - ssh -i $HOME/.ssh/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' + chmod 600 "$HOME/key" + ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' - name: Connect to Yandex Cloud uses: appleboy/ssh-action@master From b2358f521fc23f02d189f0e4c2c66bd2a7efea47 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:16:44 +0300 Subject: [PATCH 09/24] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B1=D1=83=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B2=D0=B5=D0=B1=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 37 ++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e8ec5cf..b987c68 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,19 +13,28 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - - name: Connect to Yandex Cloud on my own - run: | - echo "${{ secrets.key }}" > "$HOME/key" - chmod 600 "$HOME/key" - ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' + # - name: Connect to Yandex Cloud on my own + # run: | + # echo "${{ secrets.key }}" > "$HOME/key" + # chmod 600 "$HOME/key" + # ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' - - name: Connect to Yandex Cloud - uses: appleboy/ssh-action@master + - name: webfactory/ssh-agent + uses: webfactory/ssh-agent@v0.5.3 with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - key: ${{ secrets.KEY }} - port: ${{ secrets.PORT }} - script: | - whoami - ls -al + ssh-private-key: ${{ secrets.KEY }} + + - run: | + whois + ls -laF + + # - name: Connect to Yandex Cloud + # uses: appleboy/ssh-action@master + # with: + # host: ${{ secrets.HOST }} + # username: ${{ secrets.USERNAME }} + # key: ${{ secrets.KEY }} + # port: ${{ secrets.PORT }} + # script: | + # whoami + # ls -al From e3efed2f4fabcba11f48dac54413b1463edab814 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:18:15 +0300 Subject: [PATCH 10/24] whoami --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b987c68..dbd1065 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: ssh-private-key: ${{ secrets.KEY }} - run: | - whois + whoami ls -laF # - name: Connect to Yandex Cloud From c8fa201b5bd705125bc77cdc79500eb8926ca6a5 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 02:24:34 +0300 Subject: [PATCH 11/24] d --- .github/workflows/deploy.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dbd1065..d8dc5db 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -13,12 +13,6 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: - # - name: Connect to Yandex Cloud on my own - # run: | - # echo "${{ secrets.key }}" > "$HOME/key" - # chmod 600 "$HOME/key" - # ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' - - name: webfactory/ssh-agent uses: webfactory/ssh-agent@v0.5.3 with: @@ -28,13 +22,19 @@ jobs: whoami ls -laF - # - name: Connect to Yandex Cloud - # uses: appleboy/ssh-action@master - # with: - # host: ${{ secrets.HOST }} - # username: ${{ secrets.USERNAME }} - # key: ${{ secrets.KEY }} - # port: ${{ secrets.PORT }} - # script: | - # whoami - # ls -al + - name: Connect to Yandex Cloud on my own + run: | + echo "${{ secrets.key }}" > "$HOME/key" + chmod 600 "$HOME/key" + ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' + + - name: Connect to Yandex Cloud + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: | + whoami + ls -laF From c0164cac8223d6e2b175901b03d74683ea62aebe Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 21:29:15 +0300 Subject: [PATCH 12/24] =?UTF-8?q?ls=20=D1=81=D0=BB=D0=B5=D0=B4=D1=83=D1=8E?= =?UTF-8?q?=D1=89=D0=B5=D0=B9=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=BE?= =?UTF-8?q?=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index d8dc5db..dfc8739 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -18,23 +18,11 @@ jobs: with: ssh-private-key: ${{ secrets.KEY }} - - run: | - whoami - ls -laF - - - name: Connect to Yandex Cloud on my own + - name: Set up keys for Yandex Cloud run: | echo "${{ secrets.key }}" > "$HOME/key" chmod 600 "$HOME/key" - ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no 'ls -al' - - name: Connect to Yandex Cloud - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - key: ${{ secrets.KEY }} - port: ${{ secrets.PORT }} - script: | - whoami - ls -laF + - name: Connect to the Yandex Cloud + ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no + ls -laF From c007eccca14adb438ca5a62b7432c98312f47142 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 21:30:52 +0300 Subject: [PATCH 13/24] =?UTF-8?q?=D0=BF=D0=B0=D0=BB=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dfc8739..1ce2eb9 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,5 +24,17 @@ jobs: chmod 600 "$HOME/key" - name: Connect to the Yandex Cloud + run: | ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no ls -laF + + - name: Connect to Yandex Cloud + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.HOST }} + username: ${{ secrets.USERNAME }} + key: ${{ secrets.KEY }} + port: ${{ secrets.PORT }} + script: | + whoami + ls -laF From 23d22a857ccee70d5911cc954db06a13662f4f3b Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 21:35:39 +0300 Subject: [PATCH 14/24] git pull --- .github/workflows/deploy.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1ce2eb9..e998b0a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -24,9 +24,13 @@ jobs: chmod 600 "$HOME/key" - name: Connect to the Yandex Cloud - run: | + run: ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no - ls -laF + ' + cd Carolyn && + git pull && + + ' - name: Connect to Yandex Cloud uses: appleboy/ssh-action@master From ed0b0cad110a9979afa509600b89fc0dea9607de Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sat, 30 Oct 2021 22:08:19 +0300 Subject: [PATCH 15/24] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4?= =?UTF-8?q?=D1=8B=20=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index e998b0a..6e3d347 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -23,22 +23,12 @@ jobs: echo "${{ secrets.key }}" > "$HOME/key" chmod 600 "$HOME/key" - - name: Connect to the Yandex Cloud + - name: Pull repo and restart Docker containers run: ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no ' cd Carolyn && git pull && - + docker-compose down && + docker-compose up -d ' - - - name: Connect to Yandex Cloud - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.HOST }} - username: ${{ secrets.USERNAME }} - key: ${{ secrets.KEY }} - port: ${{ secrets.PORT }} - script: | - whoami - ls -laF From fb66f55668ffc591e140b46bbd73a0c94ceb186e Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 17:12:31 +0300 Subject: [PATCH 16/24] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D0=B5=D0=BC=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D1=83?= =?UTF-8?q?=20about?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 11 ++++------- TelegramBot/bot.py | 11 ++++++++++- TelegramBot/messages/messages.py | 10 ++++++++-- docker-compose.yml | 4 ++-- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 6e3d347..bab4d9e 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -1,17 +1,13 @@ name: deploy-to-Yandex-Cloud -# Controls when the workflow will run on: workflow_dispatch: + release: + types: [published] -# A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: - # This workflow contains a single job called "build" deploy: - # The type of runner that the job will run on runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job steps: - name: webfactory/ssh-agent uses: webfactory/ssh-agent@v0.5.3 @@ -23,12 +19,13 @@ jobs: echo "${{ secrets.key }}" > "$HOME/key" chmod 600 "$HOME/key" - - name: Pull repo and restart Docker containers + - name: Restart Bot at Yandex Cloud run: ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no ' cd Carolyn && git pull && + export CAROLYN_DEPLOY_INFO=$(git describe --always) docker-compose down && docker-compose up -d ' diff --git a/TelegramBot/bot.py b/TelegramBot/bot.py index fa03b97..2762ea9 100644 --- a/TelegramBot/bot.py +++ b/TelegramBot/bot.py @@ -4,6 +4,7 @@ import logging import requests import time import datetime +import os import telegram from telegram import ( @@ -394,9 +395,15 @@ def variant(update: Update, context: CallbackContext): msg.edit_text(text=MESSAGES.Variant.get(data["student"]["number"])) +def about(update: Update, context: CallbackContext): + """Получить инфу о развертывании бота.""" + deploy_info = os.environ.get("CAROLYN_DEPLOY_INFO") + update.message.reply_html(MESSAGES.Deploy.about(deploy_info)) + + def error(update: Update, context: CallbackContext): LOG.error(msg="Exception while handling an update:", exc_info=context.error) - if context.error is not None: + if context.error is not None and update is not None: update.message.reply_text("Ой, кажется у меня %s" % repr(context.error)) update.message.reply_sticker(MESSAGES.Stickers.DEAD) return ConversationHandler.END @@ -485,6 +492,7 @@ def main() -> None: sub_handler = CommandHandler("sub", sub) unsub_handler = CommandHandler("unsub", unsub) variant_handler = CommandHandler("variant", variant) + about_handler = CommandHandler("about", about) dispatcher.add_handler(start_handler) dispatcher.add_handler(grades_handler) @@ -492,6 +500,7 @@ def main() -> None: dispatcher.add_handler(sub_handler) dispatcher.add_handler(unsub_handler) dispatcher.add_handler(variant_handler) + dispatcher.add_handler(about_handler) dispatcher.add_error_handler(error) # Начало работы бота diff --git a/TelegramBot/messages/messages.py b/TelegramBot/messages/messages.py index 4e8bd9f..a048a43 100644 --- a/TelegramBot/messages/messages.py +++ b/TelegramBot/messages/messages.py @@ -29,8 +29,9 @@ class Messages: TIMEOUT = "🕛 Время запроса вышло" @staticmethod - def get(name: str, assignment: list, how_to_display: str, - notes: str, deadline: str): + def get( + name: str, assignment: list, how_to_display: str, notes: str, deadline: str + ): is_float, n_cols, n_rows = how_to_display.split(",") n_cols, n_rows = int(n_cols), int(n_rows) summary = f"{name}:\n" @@ -110,6 +111,11 @@ class Messages: } return cases.get(err, "😟 Возникли неполадки") + class Deploy: + @staticmethod + def about(git_info): + return f"ℹ️ Информация о сборке:\n{git_info}" + class Spreadsheets: pass diff --git a/docker-compose.yml b/docker-compose.yml index 78e283c..1e1e0ae 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -7,12 +7,12 @@ services: build: ./SpreadsheetsService ports: - "5000:5000" - environment: - SECRETKEY: "HELLO-WORLD-@21XX 15AF" volumes: - ./SpreadsheetsService:/app telegrambot: container_name: "carolyn-telegrambot" + environment: + - CAROLYN_DEPLOY_INFO restart: always build: ./TelegramBot volumes: From 8282af827be27bbb6a4559c2cf9f568d9400e5f3 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 17:13:38 +0300 Subject: [PATCH 17/24] =?UTF-8?q?=D0=B7=D0=B0=D0=B1=D1=8B=D0=BB=20=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index bab4d9e..546a6d4 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: ' cd Carolyn && git pull && - export CAROLYN_DEPLOY_INFO=$(git describe --always) + export CAROLYN_DEPLOY_INFO=$(git describe --always) && docker-compose down && docker-compose up -d ' From c6db5a5dd610080a44c20f8dafef3bbf08eb3071 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 17:29:08 +0300 Subject: [PATCH 18/24] =?UTF-8?q?=D0=BA=D0=BB=D0=B0=D0=B4=D0=B5=D0=BC=20?= =?UTF-8?q?=D0=B2=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=83?= =?UTF-8?q?=D1=8E=20=D0=BE=D0=BA=D1=80=D1=83=D0=B6=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 546a6d4..c1de0af 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,7 @@ jobs: ' cd Carolyn && git pull && - export CAROLYN_DEPLOY_INFO=$(git describe --always) && + export CAROLYN_DEPLOY_INFO="$(git rev-parse HEAD)" && docker-compose down && docker-compose up -d ' From 05f29bb382fba082e9a0724496813ea37e3ce5d6 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 17:43:15 +0300 Subject: [PATCH 19/24] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D1=81=D1=81=D1=8B=D0=BB=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=B3=D0=B8=D1=82=D1=85=D0=B0=D0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TelegramBot/bot.py | 2 +- TelegramBot/messages/messages.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/TelegramBot/bot.py b/TelegramBot/bot.py index 2762ea9..e8f1370 100644 --- a/TelegramBot/bot.py +++ b/TelegramBot/bot.py @@ -397,7 +397,7 @@ def variant(update: Update, context: CallbackContext): def about(update: Update, context: CallbackContext): """Получить инфу о развертывании бота.""" - deploy_info = os.environ.get("CAROLYN_DEPLOY_INFO") + deploy_info = os.environ.get("CAROLYN_DEPLOY_INFO", "") update.message.reply_html(MESSAGES.Deploy.about(deploy_info)) diff --git a/TelegramBot/messages/messages.py b/TelegramBot/messages/messages.py index a048a43..0d369a9 100644 --- a/TelegramBot/messages/messages.py +++ b/TelegramBot/messages/messages.py @@ -113,8 +113,8 @@ class Messages: class Deploy: @staticmethod - def about(git_info): - return f"ℹ️ Информация о сборке:\n{git_info}" + def about(commit_id: str): + return f"ℹ️ Информация о сборке:\n{commit_id:7}" class Spreadsheets: pass From 84658b825bc615b25feb8b3fefd4524982477e32 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 17:49:54 +0300 Subject: [PATCH 20/24] =?UTF-8?q?=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8=20?= =?UTF-8?q?=D0=B1=D1=83=D0=B4=D1=83=D1=82=20=D0=B2=20=D1=81=D0=BE=D0=BE?= =?UTF-8?q?=D0=B1=D1=89=D0=B5=D0=BD=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 3 ++- TelegramBot/bot.py | 5 +++-- TelegramBot/messages/messages.py | 4 ++-- docker-compose.yml | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index c1de0af..50f86c8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -25,7 +25,8 @@ jobs: ' cd Carolyn && git pull && - export CAROLYN_DEPLOY_INFO="$(git rev-parse HEAD)" && + export CAROLYN_DEPLOY_ID="$(git rev-parse HEAD)" && + export CAROLYN_DEPLOY_VERSION="$(git describe --tags)" && docker-compose down && docker-compose up -d ' diff --git a/TelegramBot/bot.py b/TelegramBot/bot.py index e8f1370..b51d68b 100644 --- a/TelegramBot/bot.py +++ b/TelegramBot/bot.py @@ -397,8 +397,9 @@ def variant(update: Update, context: CallbackContext): def about(update: Update, context: CallbackContext): """Получить инфу о развертывании бота.""" - deploy_info = os.environ.get("CAROLYN_DEPLOY_INFO", "") - update.message.reply_html(MESSAGES.Deploy.about(deploy_info)) + commit_id = os.environ.get("CAROLYN_DEPLOY_ID", "") + verison = os.environ.get("CAROLYN_DEPLOY_VERSION", "") + update.message.reply_html(MESSAGES.Deploy.about(commit_id, verison)) def error(update: Update, context: CallbackContext): diff --git a/TelegramBot/messages/messages.py b/TelegramBot/messages/messages.py index 0d369a9..baab794 100644 --- a/TelegramBot/messages/messages.py +++ b/TelegramBot/messages/messages.py @@ -113,8 +113,8 @@ class Messages: class Deploy: @staticmethod - def about(commit_id: str): - return f"ℹ️ Информация о сборке:\n{commit_id:7}" + def about(commit_id: str, git_describe): + return f"ℹ️ Версия сборки:\n{git_describe}" class Spreadsheets: pass diff --git a/docker-compose.yml b/docker-compose.yml index 1e1e0ae..cb5a00d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,7 +12,8 @@ services: telegrambot: container_name: "carolyn-telegrambot" environment: - - CAROLYN_DEPLOY_INFO + - CAROLYN_DEPLOY_ID + - CAROLYN_DEPLOY_VERSION restart: always build: ./TelegramBot volumes: From 6e4f6cc555bed8fddcaaa3fce24187f6d70685e8 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 17:59:54 +0300 Subject: [PATCH 21/24] =?UTF-8?q?=D0=BE=D1=82=D0=BB=D0=B0=D0=B6=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D1=8E=20=D0=BF=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD?= =?UTF-8?q?=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 50f86c8..2c93e63 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -27,6 +27,7 @@ jobs: git pull && export CAROLYN_DEPLOY_ID="$(git rev-parse HEAD)" && export CAROLYN_DEPLOY_VERSION="$(git describe --tags)" && + echo "$CAROLYN_DEPLOY_VERSION, $CAROLYN_DEPLOY_ID" && docker-compose down && docker-compose up -d ' From e1bfb818b88913fa391194be2e59d41862c475a5 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 18:15:06 +0300 Subject: [PATCH 22/24] =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=B1=D1=83=D1=8E=20?= =?UTF-8?q?=D0=BF=D1=80=D0=BE=D0=BA=D0=B8=D0=BD=D1=83=D1=82=D1=8C=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D1=8B=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 2 +- docker-compose.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2c93e63..04de7ab 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,7 +19,7 @@ jobs: echo "${{ secrets.key }}" > "$HOME/key" chmod 600 "$HOME/key" - - name: Restart Bot at Yandex Cloud + - name: Deploy bot at Yandex Cloud run: ssh -i $HOME/key carolyn@${{ secrets.HOST }} -o StrictHostKeyChecking=no ' diff --git a/docker-compose.yml b/docker-compose.yml index cb5a00d..782b64f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,8 @@ services: telegrambot: container_name: "carolyn-telegrambot" environment: - - CAROLYN_DEPLOY_ID - - CAROLYN_DEPLOY_VERSION + CAROLYN_DEPLOY_ID: ${CAROLYN_DEPLOY_ID} + CAROLYN_DEPLOY_VERSION: ${CAROLYN_DEPLOY_VERSION} restart: always build: ./TelegramBot volumes: From 85dc480a17a57d035edae6a8ac3d2959c35570a6 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 18:18:23 +0300 Subject: [PATCH 23/24] =?UTF-8?q?=D0=B2=D1=8B=D0=BF=D0=B8=D1=88=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=BA=D0=BE=D0=BD=D1=84=D0=B8=D0=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 04de7ab..dc362f3 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,6 +28,7 @@ jobs: export CAROLYN_DEPLOY_ID="$(git rev-parse HEAD)" && export CAROLYN_DEPLOY_VERSION="$(git describe --tags)" && echo "$CAROLYN_DEPLOY_VERSION, $CAROLYN_DEPLOY_ID" && + docker-compose config && docker-compose down && docker-compose up -d ' From ce2bfe2b93f1428297bfa68bb5ba5c4faf4b69e4 Mon Sep 17 00:00:00 2001 From: Mifarse Date: Sun, 31 Oct 2021 18:21:41 +0300 Subject: [PATCH 24/24] =?UTF-8?q?=D0=B5=D1=81=D0=BB=D0=B8=20=D0=BD=D0=B5?= =?UTF-8?q?=20=D0=B7=D0=B0=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=B0=D0=B5=D1=82?= =?UTF-8?q?,=20=D1=8F=20=D1=81=D0=BE=D0=B9=D0=B4=D1=83=20=D1=81=20=D1=83?= =?UTF-8?q?=D0=BC=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index dc362f3..04de7ab 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -28,7 +28,6 @@ jobs: export CAROLYN_DEPLOY_ID="$(git rev-parse HEAD)" && export CAROLYN_DEPLOY_VERSION="$(git describe --tags)" && echo "$CAROLYN_DEPLOY_VERSION, $CAROLYN_DEPLOY_ID" && - docker-compose config && docker-compose down && docker-compose up -d '