diff --git a/.github/.actions/ssh_auth.yml b/.github/.actions/ssh_auth.yml new file mode 100644 index 0000000..4a57d2f --- /dev/null +++ b/.github/.actions/ssh_auth.yml @@ -0,0 +1,14 @@ +name: 'SSH Auth' +runs: + using: 'composite' + steps: + - name: Set up SSH + uses: webfactory/ssh-agent@v0.7.0 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Generate auth hosts + run: ssh-keyscan -H ${{ vars.SERVER_HOST }} >> ~/.ssh/known_hosts + + - name: Check connection + run: ssh ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} whoami \ No newline at end of file diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index aec170d..b04278d 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -30,16 +30,8 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Set up SSH - uses: webfactory/ssh-agent@v0.7.0 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Generate auth hosts - run: ssh-keyscan -H ${{ vars.SERVER_HOST }} >> ~/.ssh/known_hosts - - - name: Check connection - run: ssh ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }} whoami + - name: Auth SSH + uses: ./.github/.actions/ssh_auth - name: Sync with server run: rsync -avz --exclude='.env' ./ ${{ vars.SERVER_USER }}@${{ vars.SERVER_HOST }}:${{ vars.SERVER_DIR }} @@ -56,4 +48,33 @@ jobs: ssh $SERVER_USER@$SERVER_HOST << EOF cd $SERVER_DIR docker compose up -d - EOF \ No newline at end of file + EOF + + - name: Download report req + run: pip install -r ./utils/requirements.txt + + - name: Send report + env: + TG_TOKEN: ${{ secrets.TG_TOKEN }} + TG_CHAT_ID: ${{ vars.TG_CHAT_ID }} + run: python3 ./utils/send_result.py success + + fail-report: + runs-on: self-hosted + if: failure() + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Auth SSH + uses: ./.github/.actions/ssh_auth + + - name: Download report req + run: pip install -r ./utils/requirements.txt + + - name: Send report + env: + TG_TOKEN: ${{ secrets.TG_TOKEN }} + TG_CHAT_ID: ${{ vars.TG_CHAT_ID }} + run: python3 ./utils/send_result.py fail \ No newline at end of file diff --git a/meeting-2107.code-workspace b/meeting-2107.code-workspace new file mode 100644 index 0000000..8164b8d --- /dev/null +++ b/meeting-2107.code-workspace @@ -0,0 +1,17 @@ +{ + "folders": [ + { + "name": "meeting-2107", + "path": "." + }, + { + "name": "backend", + "path": "backend" + }, + { + "name": "bot", + "path": "bot" + } + ], + "settings": {} +} \ No newline at end of file diff --git a/utils/requirements.txt b/utils/requirements.txt new file mode 100644 index 0000000..663bd1f --- /dev/null +++ b/utils/requirements.txt @@ -0,0 +1 @@ +requests \ No newline at end of file diff --git a/utils/send_result.py b/utils/send_result.py new file mode 100644 index 0000000..f6d1276 --- /dev/null +++ b/utils/send_result.py @@ -0,0 +1,14 @@ +import requests, sys, os + +def send(text: str) -> None: + requests.post(f"https://api.telegram.org/bot{os.environ.get("TG_TOKEN")}/sendMessage", json={ + "chat_id": os.environ.get("TG_CHAT_ID"), + "text": text, + "parse_mode": "markdown" + }) + +match sys.argv[1]: + case "success": + send("🌐 Процесс сборки успешно завершён") + case "fail": + send("❌ Сборка провалена.\n@zoomdevs @ramchike") \ No newline at end of file