From 560adb4479d84629af6dc5b6acbb543deb7b450d Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Thu, 31 Aug 2023 23:30:35 +0300 Subject: [PATCH 01/21] realize service for prod and stage --- .github/workflows/deploy-bot-on-prod.yml | 15 ++++++++++++ .github/workflows/deploy-bot-on-stage.yml | 15 ++++++++++++ infra/dev/spread_wings_bot.service | 29 +++++++++++++++++++++++ infra/prod/spread_wings_bot.service | 29 +++++++++++++++++++++++ 4 files changed, 88 insertions(+) create mode 100644 infra/dev/spread_wings_bot.service create mode 100644 infra/prod/spread_wings_bot.service diff --git a/.github/workflows/deploy-bot-on-prod.yml b/.github/workflows/deploy-bot-on-prod.yml index 41ff240e..e43e70ff 100644 --- a/.github/workflows/deploy-bot-on-prod.yml +++ b/.github/workflows/deploy-bot-on-prod.yml @@ -13,6 +13,14 @@ jobs: name: prod_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - name: copy service file + uses: appleboy/scp-action@v0.1.4 + with: + host: ${{ secrets.VM_HOST }} + username: ${{ secrets.VM_USER }} + password: ${{ secrets.VM_PASSWORD }} + source: "infra/prod/spread_wings_bot.service" + target: /home/deploy/spread_wings_bot/infra/prod/ - name: ssh pull and start uses: appleboy/ssh-action@master with: @@ -61,6 +69,13 @@ jobs: # Cleaning unused containers, images, networks docker system prune --force + # Installing defend service for app + # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать + # scp infra/prod/spread_wings_bot.service . + cp -f /home/deploy/spread_wings_bot/infra/prod/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service + systemctl daemon-reload + systemctl restart spread_wings_bot.service + # Installing the app docker-compose -f docker-compose.stage.yaml stop docker-compose -f docker-compose.stage.yaml pull diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index ddb5adfd..92b15111 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -13,6 +13,14 @@ jobs: name: stage_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - name: copy service file + uses: appleboy/scp-action@v0.1.4 + with: + host: ${{ secrets.VM_HOST }} + username: ${{ secrets.VM_USER }} + password: ${{ secrets.VM_PASSWORD }} + source: "infra/dev/spread_wings_bot.service" + target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master with: @@ -61,6 +69,13 @@ jobs: # Cleaning unused containers, images, networks docker system prune --force + # Installing defend service for app + # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать + # scp infra/dev/spread_wings_bot.service . + cp -f /home/deploy/spread_wings_bot/infra/dev/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service + systemctl daemon-reload + systemctl restart spread_wings_bot.service + # Installing the app docker-compose -f docker-compose.stage.yaml stop docker-compose -f docker-compose.stage.yaml pull diff --git a/infra/dev/spread_wings_bot.service b/infra/dev/spread_wings_bot.service new file mode 100644 index 00000000..f113e18e --- /dev/null +++ b/infra/dev/spread_wings_bot.service @@ -0,0 +1,29 @@ +[Unit] + +Description=spread_wings_bot +Requires=docker.service +After=docker.service + +[Service] + +Restart=always +RestartSec=5 +TimeOutStartSec=1200 +User=root + +WorkingDirectory=/home/deploy/spread_wings_bot/infra/dev/ + +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull bot +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull db +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull redis +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env pull nginx +ExecStartPre=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env down + +# compose up +ExecStart=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env up + +# compose down +ExecStop=docker-compose -f docker-compose.stage.yaml --env-file /home/deploy/spread_wings_bot/infra/dev/.env down + +[Install] +WantedBy=multi-user.target diff --git a/infra/prod/spread_wings_bot.service b/infra/prod/spread_wings_bot.service new file mode 100644 index 00000000..cd002a73 --- /dev/null +++ b/infra/prod/spread_wings_bot.service @@ -0,0 +1,29 @@ +[Unit] + +Description=spread_wings_bot +Requires=docker.service +After=docker.service + +[Service] + +Restart=always +RestartSec=5 +TimeOutStartSec=1200 +User=root + +WorkingDirectory=/home/deploy/spread_wings_bot/infra/prod/ + +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull bot +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull db +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull redis +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env pull nginx +ExecStartPre=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env down + +# compose up +ExecStart=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env up + +# compose down +ExecStop=docker-compose -f docker-compose.prod.yaml --env-file /home/deploy/spread_wings_bot/infra/prod/.env down + +[Install] +WantedBy=multi-user.target From eaf2d8f9283b2c9cf66120e7c3226847427e367b Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sat, 2 Sep 2023 22:06:59 +0300 Subject: [PATCH 02/21] fix workflow --- .github/workflows/deploy-bot-on-prod.yml | 11 +++++------ .github/workflows/deploy-bot-on-stage.yml | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/deploy-bot-on-prod.yml b/.github/workflows/deploy-bot-on-prod.yml index e43e70ff..547e4484 100644 --- a/.github/workflows/deploy-bot-on-prod.yml +++ b/.github/workflows/deploy-bot-on-prod.yml @@ -19,7 +19,7 @@ jobs: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "infra/prod/spread_wings_bot.service" + source: "infra/prod/" target: /home/deploy/spread_wings_bot/infra/prod/ - name: ssh pull and start uses: appleboy/ssh-action@master @@ -29,7 +29,6 @@ jobs: password: ${{ secrets.VM_PASSWORD }} script: | cd /home/deploy/spread_wings_bot/infra/prod/ - git pull rm .env touch .env @@ -71,10 +70,10 @@ jobs: # Installing defend service for app # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать - # scp infra/prod/spread_wings_bot.service . - cp -f /home/deploy/spread_wings_bot/infra/prod/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service - systemctl daemon-reload - systemctl restart spread_wings_bot.service + # scp infra/prod/spread_wings_bot.service ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/spread_wings_bot/infra/prod/ + sudo cp -f /home/deploy/spread_wings_bot/infra/prod/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service + sudo systemctl daemon-reload + sudo systemctl restart spread_wings_bot.service # Installing the app docker-compose -f docker-compose.stage.yaml stop diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 92b15111..82b2f35c 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -19,7 +19,7 @@ jobs: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "infra/dev/spread_wings_bot.service" + source: "infra/dev/" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master @@ -29,7 +29,6 @@ jobs: password: ${{ secrets.VM_PASSWORD }} script: | cd /home/deploy/spread_wings_bot/infra/dev/ - git pull rm .env touch .env @@ -71,10 +70,10 @@ jobs: # Installing defend service for app # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать - # scp infra/dev/spread_wings_bot.service . - cp -f /home/deploy/spread_wings_bot/infra/dev/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service - systemctl daemon-reload - systemctl restart spread_wings_bot.service + # scp infra/dev/spread_wings_bot.service ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/spread_wings_bot/infra/dev/ + sudo cp -f /home/deploy/spread_wings_bot/infra/dev/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service + sudo systemctl daemon-reload + sudo systemctl restart spread_wings_bot.service # Installing the app docker-compose -f docker-compose.stage.yaml stop From bf6b88789ad5513ea615f64c08a802897f43b85c Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> Date: Sun, 3 Sep 2023 12:54:00 +0300 Subject: [PATCH 03/21] Fix/deploy.service (#264) * test fix * test2 --- .github/workflows/deploy-bot-on-stage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 4352a995..0cfaebea 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -20,7 +20,7 @@ jobs: username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} port: 22 - source: "infra/dev/spread_wings_bot.service" + source: "./infra/dev/spread_wings_bot.service" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master From 48380e191e25adba0b38d00ff368ffacb7457546 Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> Date: Sun, 3 Sep 2023 13:09:58 +0300 Subject: [PATCH 04/21] Fix/deploy.service (#265) * test fix * test2 * test3 --- .github/workflows/deploy-bot-on-stage.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 0cfaebea..549811a3 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -13,14 +13,20 @@ jobs: name: stage_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - name: Run a multi-line script + uses: actions/checkout@v2 + run: | + mkdir ../spread_wings_bot/infra/dev/ + cp -TR . ../spread_wings_bot/infra/dev/ + tar -cvf deploy.tar ../spread_wings_bot/infra/dev/ + - name: copy service file uses: appleboy/scp-action@v0.1.4 with: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - port: 22 - source: "./infra/dev/spread_wings_bot.service" + source: "deploy.tar" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master From 736bc25344f89c54d1c997dc61e1bae5f77f1544 Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> Date: Sun, 3 Sep 2023 13:13:01 +0300 Subject: [PATCH 05/21] Fix/deploy.service (#266) * test fix * test2 * test3 * test3fix --- .github/workflows/deploy-bot-on-stage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 549811a3..35f251c7 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -14,7 +14,7 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - name: Run a multi-line script - uses: actions/checkout@v2 + # uses: actions/checkout@v2 run: | mkdir ../spread_wings_bot/infra/dev/ cp -TR . ../spread_wings_bot/infra/dev/ From 22ab47eb81d2c35f962e14c2496874e1f21c4b67 Mon Sep 17 00:00:00 2001 From: bobr <99394921+bobr2072@users.noreply.github.com> Date: Sun, 3 Sep 2023 20:38:29 +0300 Subject: [PATCH 06/21] removed unique=True in coordinator model for phone and telegram (#267) --- ...alter_coordinator_phone_number_and_more.py | 49 +++++++++++++++++++ src/bot/models.py | 2 - 2 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 src/bot/migrations/0008_alter_coordinator_phone_number_and_more.py diff --git a/src/bot/migrations/0008_alter_coordinator_phone_number_and_more.py b/src/bot/migrations/0008_alter_coordinator_phone_number_and_more.py new file mode 100644 index 00000000..51eea2b1 --- /dev/null +++ b/src/bot/migrations/0008_alter_coordinator_phone_number_and_more.py @@ -0,0 +1,49 @@ +# Generated by Django 4.2.4 on 2023-09-03 17:19 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + """Migrations for bot.""" + + dependencies = [ + ("bot", "0007_alter_question_short_description"), + ] + + operations = [ + migrations.AlterField( + model_name="coordinator", + name="phone_number", + field=models.CharField( + blank=True, + help_text="Введите номер телефона регионального координатора", + max_length=20, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Введите номер телефона в формате: +7 (777) 777-77-77", + regex="^[\\+]?[7, 8][-\\s\\.]?[(]?[0-9]{3}[)]?[-\\s\\.]?[0-9]{3}[-\\s\\.]?[0-9]{2}[-\\s\\.]?[0-9]{2}$", + ) + ], + verbose_name="Номер телефона", + ), + ), + migrations.AlterField( + model_name="coordinator", + name="telegram_account", + field=models.CharField( + blank=True, + help_text="Введите телеграмм-аккаунт регионального координатора", + max_length=32, + null=True, + validators=[ + django.core.validators.RegexValidator( + message="Введите название аккаунта telegram в формате: username", + regex="^[\\w\\_]{5,32}$", + ) + ], + verbose_name="Telegram", + ), + ), + ] diff --git a/src/bot/models.py b/src/bot/models.py index f87828bd..da9b93a4 100644 --- a/src/bot/models.py +++ b/src/bot/models.py @@ -40,7 +40,6 @@ class Coordinator(BaseModel): ) phone_number = models.CharField( max_length=20, - unique=True, validators=[phone_regex], blank=True, null=True, @@ -49,7 +48,6 @@ class Coordinator(BaseModel): ) telegram_account = models.CharField( max_length=32, - unique=True, validators=[telegram_regex], blank=True, null=True, From 4b80ed89f4ea8c696a3bbe907e98864b37dead67 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 21:21:55 +0300 Subject: [PATCH 07/21] fix stage workflow --- .github/workflows/deploy-bot-on-stage.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 82b2f35c..4e386014 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -13,14 +13,20 @@ jobs: name: stage_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - uses: actions/checkout@v2 + - name: Run a multi-line script + run: | + mkdir ../build + cp -TR . ../build + tar -cvf deploy.tar ../build/ - name: copy service file uses: appleboy/scp-action@v0.1.4 with: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "infra/dev/" - target: /home/deploy/spread_wings_bot/infra/dev/ + source: "deploy.tar" + target: /spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master with: From 6b0b358fbf49fa44d65e91a1056801ebbd4dd79b Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 21:32:32 +0300 Subject: [PATCH 08/21] Feature/realize service for stage and prod (#269) * realize service for prod and stage * fix workflow * fix stage workflow --------- Co-authored-by: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> --- .github/workflows/deploy-bot-on-stage.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 35f251c7..4e386014 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -13,13 +13,12 @@ jobs: name: stage_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: + - uses: actions/checkout@v2 - name: Run a multi-line script - # uses: actions/checkout@v2 run: | - mkdir ../spread_wings_bot/infra/dev/ - cp -TR . ../spread_wings_bot/infra/dev/ - tar -cvf deploy.tar ../spread_wings_bot/infra/dev/ - + mkdir ../build + cp -TR . ../build + tar -cvf deploy.tar ../build/ - name: copy service file uses: appleboy/scp-action@v0.1.4 with: @@ -27,7 +26,7 @@ jobs: username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} source: "deploy.tar" - target: /home/deploy/spread_wings_bot/infra/dev/ + target: /spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master with: From 89e576500745acf0dbb5232f02c35b9ffeb743b8 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 21:59:55 +0300 Subject: [PATCH 09/21] fix stage workflow --- .github/workflows/deploy-bot-on-stage.yml | 2 +- .gitignore | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 4e386014..aabe69a8 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -26,7 +26,7 @@ jobs: username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} source: "deploy.tar" - target: /spread_wings_bot/infra/dev/ + target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master with: diff --git a/.gitignore b/.gitignore index 006002f7..69640e39 100644 --- a/.gitignore +++ b/.gitignore @@ -144,3 +144,4 @@ local_persistence # Others coordinator_contacts.html +static/ From 4960d11968b60640459e5a924d0ef00cfb0d0641 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 22:10:57 +0300 Subject: [PATCH 10/21] Update deploy-bot-on-stage.yml --- .github/workflows/deploy-bot-on-stage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 4e386014..aabe69a8 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -26,7 +26,7 @@ jobs: username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} source: "deploy.tar" - target: /spread_wings_bot/infra/dev/ + target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master with: From 22badb938d2d8d28c505d8e608c8be2c225dc25d Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 22:27:34 +0300 Subject: [PATCH 11/21] Update deploy-bot-on-stage.yml (#271) --- .github/workflows/deploy-bot-on-stage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 4e386014..aabe69a8 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -26,7 +26,7 @@ jobs: username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} source: "deploy.tar" - target: /spread_wings_bot/infra/dev/ + target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master with: From ecc4f2214c76e5edf548fbdb995f2327f814d624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D1=81?= =?UTF-8?q?=D0=B0=D1=82=D0=BA=D0=B8=D0=BD?= Date: Sun, 3 Sep 2023 22:39:30 +0300 Subject: [PATCH 12/21] =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=BD=D0=B0=D0=B7=D0=B2=D0=B0=D0=BD?= =?UTF-8?q?=D0=B8=D1=8F.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 ++-- src/bot_settings/migrations/0002_add_settings.py | 2 +- src/config/urls.py | 4 ++-- src/templates/password_reset_email.html | 2 +- src/utils/emailing/reset_password.py | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e5f1a158..82191979 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Бот для фонда "Расправь крылья" +# Бот для фонда "Расправь крылья!" -#### Проект телеграм-бота, который позволяет всем желающим и нуждающимся получить ответы на все необходимые вопросы в телеграме. [“Расправь крылья”](https://detskyfond.info/). +#### Проект телеграм-бота, который позволяет всем желающим и нуждающимся получить ответы на все необходимые вопросы в телеграме. [“Расправь крылья!”](https://detskyfond.info/). Бот забирает необходимые вопросы и контакты с базы данных сайта на CMS Wordpress. diff --git a/src/bot_settings/migrations/0002_add_settings.py b/src/bot_settings/migrations/0002_add_settings.py index 7876496e..adabdbe1 100644 --- a/src/bot_settings/migrations/0002_add_settings.py +++ b/src/bot_settings/migrations/0002_add_settings.py @@ -29,7 +29,7 @@ def create_start_message_setting(apps, schema_editor): key="start_message", title="Сообщение при нажатии на кнопку Start", type=BotSettingsModel.TEXT, - value='Здравствуйте! Это бот фонда "Расправь крылья".', + value='Здравствуйте! Это бот фонда "Расправь крылья!".', ) diff --git a/src/config/urls.py b/src/config/urls.py index c6e31d51..53156bea 100644 --- a/src/config/urls.py +++ b/src/config/urls.py @@ -10,5 +10,5 @@ ] urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT) -admin.site.site_header = "Бот фонда 'Расправь крылья'" -admin.site.site_title = "Бот фонда 'Расправь крылья'" +admin.site.site_header = "Бот фонда 'Расправь крылья!'" +admin.site.site_title = "Бот фонда 'Расправь крылья!'" diff --git a/src/templates/password_reset_email.html b/src/templates/password_reset_email.html index 487d671a..64666965 100644 --- a/src/templates/password_reset_email.html +++ b/src/templates/password_reset_email.html @@ -1,5 +1,5 @@ {% extends "email.html" %} -{% block subject %}Доступ к админ-панели бота фонда "Расправь Крылья"{% endblock %} +{% block subject %}Доступ к админ-панели бота фонда "Расправь Крылья!"{% endblock %} {% block content %}
{% if message %} diff --git a/src/utils/emailing/reset_password.py b/src/utils/emailing/reset_password.py index 2585b0a7..dc79fe2a 100644 --- a/src/utils/emailing/reset_password.py +++ b/src/utils/emailing/reset_password.py @@ -16,7 +16,7 @@ def send_password_reset_email(instance: User, message=None, template=None): template = "password_reset_email.html" reset_link = get_password_reset_link(instance) email = render_email_message( - subject='Доступ к админ-панели бота "Расправь крылья"', + subject='Доступ к админ-панели бота "Расправь крылья!"', context={"password_reset_link": reset_link, "message": message}, from_email=settings.EMAIL_HOST_USER, to=[ From 0580aa41e8b7482ba8dbf9a46e91ff7f73078e20 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 22:58:55 +0300 Subject: [PATCH 13/21] Feature/realize service for stage and prod (#274) * fix stage workflow * fix stage workflow --- .github/workflows/deploy-bot-on-stage.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index aabe69a8..883b459e 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -13,19 +13,19 @@ jobs: name: stage_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - uses: actions/checkout@v2 - - name: Run a multi-line script - run: | - mkdir ../build - cp -TR . ../build - tar -cvf deploy.tar ../build/ - - name: copy service file + # - uses: actions/checkout@v2 + # - name: Run a multi-line script + # run: | + # mkdir ../build + # cp -TR ./infra/dev ../build + # tar -cvf deploy.tar ../build/ + - name: copy infra/dev uses: appleboy/scp-action@v0.1.4 with: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "deploy.tar" + source: "./infra/dev" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master From 272239d866ed43358ff0871656441bbfc7a189e4 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Sun, 3 Sep 2023 23:34:13 +0300 Subject: [PATCH 14/21] Feature/realize service for stage and prod (#275) --- .github/workflows/deploy-bot-on-stage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 883b459e..8895e308 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -25,7 +25,7 @@ jobs: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "./infra/dev" + source: "infra/dev" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master From f28c47360099ad27625068b6d7fc75d663391c54 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Mon, 4 Sep 2023 00:24:11 +0300 Subject: [PATCH 15/21] Feature/realize service for stage and prod (#276) --- .github/workflows/deploy-bot-on-stage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 8895e308..ba3de7dd 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -14,7 +14,7 @@ jobs: if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: # - uses: actions/checkout@v2 - # - name: Run a multi-line script + # - name: Prepare infra/dev # run: | # mkdir ../build # cp -TR ./infra/dev ../build @@ -25,7 +25,7 @@ jobs: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "infra/dev" + source: "infra/dev/*" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master From 94a501fc70fccdf5a1cc3a2ab362b85a91026e15 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Mon, 4 Sep 2023 08:06:08 +0300 Subject: [PATCH 16/21] Feature/realize service for stage and prod (#277) --- .github/workflows/deploy-bot-on-stage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index ba3de7dd..8895907e 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -25,7 +25,7 @@ jobs: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "infra/dev/*" + source: infra/dev/* target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master From 9258874071de45ca8e04bfbd555f80f43f3192b7 Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Mon, 4 Sep 2023 21:15:25 +0300 Subject: [PATCH 17/21] Feature/realize service for stage and prod (#278) * fix stage workflow * fix stage workflow * fix stage workflow * Fix stage workflow * fix workflow * fix stage workflow --- .github/workflows/deploy-bot-on-stage.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 8895907e..7022a12b 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -13,19 +13,19 @@ jobs: name: stage_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - # - uses: actions/checkout@v2 - # - name: Prepare infra/dev - # run: | - # mkdir ../build - # cp -TR ./infra/dev ../build - # tar -cvf deploy.tar ../build/ + - uses: actions/checkout@v2 + - name: Prepare infra/dev + run: | + mkdir ../build + cp -TR ./infra/dev ../build + # tar -cvf deploy.tar ../build/ - name: copy infra/dev uses: appleboy/scp-action@v0.1.4 with: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: infra/dev/* + source: ../build/ target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master From 32a5868bae034d74f0124280dcb06c6a8ceec57d Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Mon, 4 Sep 2023 22:29:46 +0300 Subject: [PATCH 18/21] Feature/realize service for stage and prod (#279) * fix stage workflow * fix stage workflow * fix stage workflow * Fix stage workflow * fix workflow * fix stage workflow * fix stage workflow --- .github/workflows/deploy-bot-on-stage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 7022a12b..2ef07853 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -18,14 +18,14 @@ jobs: run: | mkdir ../build cp -TR ./infra/dev ../build - # tar -cvf deploy.tar ../build/ + tar -cvf deploy.tar ../build/ - name: copy infra/dev uses: appleboy/scp-action@v0.1.4 with: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: ../build/ + source: "deploy.tar" target: /home/deploy/spread_wings_bot/infra/dev/ - name: ssh pull and start uses: appleboy/ssh-action@master @@ -35,6 +35,7 @@ jobs: password: ${{ secrets.VM_PASSWORD }} script: | cd /home/deploy/spread_wings_bot/infra/dev/ + tar -xvf deploy.tar rm .env touch .env From fd4a668f746a5d34f9caa5a6de7649127dc4b5aa Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:04:58 +0300 Subject: [PATCH 19/21] Feature/realize service for stage and prod (#280) * fix stage workflow * fix stage workflow * fix stage workflow * Fix stage workflow * fix workflow * fix stage workflow * fix stage workflow * fix stage workflow * fix stage workflow --- .github/workflows/deploy-bot-on-stage.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 2ef07853..79eea6b9 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -35,7 +35,8 @@ jobs: password: ${{ secrets.VM_PASSWORD }} script: | cd /home/deploy/spread_wings_bot/infra/dev/ - tar -xvf deploy.tar + tar -xvf deploy.tar --strip-components 1 + rm deploy.tar rm .env touch .env From 638ae895d1be80d8bed99a9bdd5a85b8674c3806 Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:29:02 +0300 Subject: [PATCH 20/21] fix (#281) --- .github/workflows/deploy-bot-on-stage.yml | 7 ------- infra/dev/docker-compose.stage.yaml | 8 ++++---- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 79eea6b9..d47f05af 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -77,17 +77,10 @@ jobs: docker system prune --force # Installing defend service for app - # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать - # scp infra/dev/spread_wings_bot.service ${{ secrets.VM_USER }}@${{ secrets.VM_HOST }}:/spread_wings_bot/infra/dev/ sudo cp -f /home/deploy/spread_wings_bot/infra/dev/spread_wings_bot.service /etc/systemd/system/spread_wings_bot.service sudo systemctl daemon-reload sudo systemctl restart spread_wings_bot.service - # Installing the app - docker-compose -f docker-compose.stage.yaml stop - docker-compose -f docker-compose.stage.yaml pull - docker-compose -f docker-compose.stage.yaml up -d - # Applying initialization commands docker exec spread-wings-bot python manage.py migrate docker exec spread-wings-bot python manage.py collectstatic --noinput diff --git a/infra/dev/docker-compose.stage.yaml b/infra/dev/docker-compose.stage.yaml index 8f65f46c..4a1f987f 100644 --- a/infra/dev/docker-compose.stage.yaml +++ b/infra/dev/docker-compose.stage.yaml @@ -18,7 +18,7 @@ services: volumes: - ./redis.conf:/usr/local/etc/redis.conf - data_value:/data - - ./logs/redis/:/var/log/ + - ../../logs/redis/:/var/log/ networks: - spread-wings-network @@ -33,7 +33,7 @@ services: - "5432:5432" volumes: - db_data:/var/lib/postgresql/data - - ./logs/db/:/var/log/postgres + - ../../logs/db/:/var/log/postgres restart: always networks: - spread-wings-network @@ -47,7 +47,7 @@ services: volumes: - ../../static:/app/src/staticfiles - ../../media:/app/src/media - - ./logs/bot/:/app/src/logs + - ../../logs/bot/:/app/src/logs restart: always env_file: - ./.env @@ -63,7 +63,7 @@ services: - ./nginx.stage.conf.template:/etc/nginx/templates/default.conf.template - ../../static:/var/html/static/ - ../../media:/var/html/media/ - - ./logs/nginx/:/var/log/nginx/ + - ../../logs/nginx/:/var/log/nginx/ env_file: - ./.env depends_on: From 935b66ea3315b8a81e5185bdd95c7cda3ada77b0 Mon Sep 17 00:00:00 2001 From: Konstantin Raikhert <69113745+KonstantinRaikhert@users.noreply.github.com> Date: Tue, 5 Sep 2023 18:45:09 +0300 Subject: [PATCH 21/21] Fix/dev ci cd (#282) * fix * fix docker --- .github/workflows/deploy-bot-on-stage.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index d47f05af..dceba997 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -82,5 +82,6 @@ jobs: sudo systemctl restart spread_wings_bot.service # Applying initialization commands + sleep 7 docker exec spread-wings-bot python manage.py migrate docker exec spread-wings-bot python manage.py collectstatic --noinput