From b49d9f2f445a704101fc9c69bf379b9b1b5df8ea Mon Sep 17 00:00:00 2001 From: Elena Shovtyuk <110084590+elenashovtyuk@users.noreply.github.com> Date: Tue, 5 Sep 2023 21:00:26 +0300 Subject: [PATCH] fix prod workflow --- .github/workflows/deploy-bot-on-prod.yml | 24 ++++++++++++------- .github/workflows/deploy-bot-on-stage.yml | 2 -- ....service => spread_wings_bot_prod.service} | 0 3 files changed, 15 insertions(+), 11 deletions(-) rename infra/prod/{spread_wings_bot.service => spread_wings_bot_prod.service} (100%) diff --git a/.github/workflows/deploy-bot-on-prod.yml b/.github/workflows/deploy-bot-on-prod.yml index 547e448..8efd1c9 100644 --- a/.github/workflows/deploy-bot-on-prod.yml +++ b/.github/workflows/deploy-bot-on-prod.yml @@ -13,13 +13,19 @@ jobs: name: prod_deploy if: ${{ github.event.workflow_run.conclusion == 'success' }} steps: - - name: copy service file + - uses: actions/checkout@v2 + - name: Prepare infra/prod + run: | + mkdir ../build + cp -TR ./infra/prod ../build + tar -cvf deploy.tar ../build/ + - name: copy infra/prod uses: appleboy/scp-action@v0.1.4 with: host: ${{ secrets.VM_HOST }} username: ${{ secrets.VM_USER }} password: ${{ secrets.VM_PASSWORD }} - source: "infra/prod/" + source: "deploy.tar" target: /home/deploy/spread_wings_bot/infra/prod/ - name: ssh pull and start uses: appleboy/ssh-action@master @@ -29,6 +35,8 @@ jobs: password: ${{ secrets.VM_PASSWORD }} script: | cd /home/deploy/spread_wings_bot/infra/prod/ + tar -xvf deploy.tar --strip-components 1 + rm deploy.tar rm .env touch .env @@ -69,16 +77,14 @@ jobs: docker system prune --force # Installing defend service for app - # Шаг с копированием в строках 16-23 можно заменить командой ниже - нужно тестировать - # 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 cp -f /home/deploy/spread_wings_bot/infra/prod/spread_wings_bot_prod.service /etc/systemd/system/spread_wings_bot_prod.service sudo systemctl daemon-reload - sudo systemctl restart spread_wings_bot.service + sudo systemctl restart spread_wings_bot_prod.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 + docker-compose -f docker-compose.prod.yaml stop + docker-compose -f docker-compose.prod.yaml pull + docker-compose -f docker-compose.prod.yaml up -d # Applying initialization commands docker exec spread-wings-bot python manage.py migrate diff --git a/.github/workflows/deploy-bot-on-stage.yml b/.github/workflows/deploy-bot-on-stage.yml index 79eea6b..45eaf9b 100644 --- a/.github/workflows/deploy-bot-on-stage.yml +++ b/.github/workflows/deploy-bot-on-stage.yml @@ -77,8 +77,6 @@ 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 diff --git a/infra/prod/spread_wings_bot.service b/infra/prod/spread_wings_bot_prod.service similarity index 100% rename from infra/prod/spread_wings_bot.service rename to infra/prod/spread_wings_bot_prod.service