Skip to content

Commit

Permalink
Workflow report
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoom-Developer committed Nov 3, 2024
1 parent b0f8e98 commit e07a3b1
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 11 deletions.
14 changes: 14 additions & 0 deletions .github/.actions/ssh_auth.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'SSH Auth'
runs:
using: 'composite'
steps:
- name: Set up SSH
uses: webfactory/[email protected]
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
43 changes: 32 additions & 11 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,8 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up SSH
uses: webfactory/[email protected]
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 }}
Expand All @@ -56,4 +48,33 @@ jobs:
ssh $SERVER_USER@$SERVER_HOST << EOF
cd $SERVER_DIR
docker compose up -d
EOF
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
17 changes: 17 additions & 0 deletions meeting-2107.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"folders": [
{
"name": "meeting-2107",
"path": "."
},
{
"name": "backend",
"path": "backend"
},
{
"name": "bot",
"path": "bot"
}
],
"settings": {}
}
1 change: 1 addition & 0 deletions utils/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
requests
14 changes: 14 additions & 0 deletions utils/send_result.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit e07a3b1

Please sign in to comment.