feat: added notification for telegram #8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: CI | |
| on: | |
| push: | |
| branches: | |
| - "*" | |
| workflow_dispatch: | |
| jobs: | |
| lint: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - run: pip install flake8 | |
| - run: flake8 app/ | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: pip install -r app/requirements.txt | |
| - name: Run tests | |
| run: pytest app/ | |
| build-and-push: | |
| needs: [lint, test] | |
| runs-on: ubuntu-latest | |
| environment: dev | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| if: github.ref == 'refs/heads/main' | |
| uses: docker/build-push-action@v3 | |
| with: | |
| push: true | |
| tags: ${{ secrets.DOCKERHUB_USERNAME }}/task-manager:${{ github.sha }} | |
| notify: | |
| needs: build-and-push | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Send positive Telegram notification | |
| if: needs.build-and-push.result == 'success' | |
| run: | | |
| curl -s -X POST \ | |
| https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \ | |
| -d chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \ | |
| -d text="✅ ${{ github.actor }} → ${{ github.repository }} успешно задеплоен" | |
| - name: Send negative Telegram notification | |
| if: needs.build-and-push.result == 'failure' | |
| run: | | |
| curl -s -X POST \ | |
| https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \ | |
| -d chat_id=${{ secrets.TELEGRAM_CHAT_ID }} \ | |
| -d text="❌ ${{ github.actor }} → ${{ github.repository }} упал!" |