From 7f54789e0c40f960d91a6bca8a400455e13b8e85 Mon Sep 17 00:00:00 2001 From: tebarius Date: Sun, 22 Feb 2026 18:17:46 +0100 Subject: [PATCH] add telegram_bot --- .gitea/workflows/trivy_image_scan.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.gitea/workflows/trivy_image_scan.yml b/.gitea/workflows/trivy_image_scan.yml index 99001cd..b3bcf05 100644 --- a/.gitea/workflows/trivy_image_scan.yml +++ b/.gitea/workflows/trivy_image_scan.yml @@ -66,3 +66,29 @@ jobs: --ignore-unfixed \ --platform linux/arm/v7 \ ${{ env.registry_gitea }}/${{ env.user }}/${{ env.image_name_gitea }}:${{ env.image_tag }} + + telegram-notify: + needs: trivy_image_scan + if: always() + runs-on: ubuntu-latest + steps: + - name: Telegram Alert + run: | + case "${{ needs.trivy_image_scan.result }}" in + "success") EMOJI="✅"; MSG="OK" ;; + "failure") EMOJI="❌"; MSG="WARN!" ;; + "cancelled") EMOJI="⏹️"; MSG="Canceled" ;; + *) EMOJI="❓"; MSG="Unknown-State: ${{ needs.trivy_image_scan.result }}" ;; + esac + + curl -s -X POST "https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage" \ + -H 'Content-Type: application/json' \ + -d "{ + \"chat_id\": \"${{ secrets.TELEGRAM_CHAT_ID }}\", + \"parse_mode\": \"HTML\", + \"text\": + \"$EMOJI $MSG - Scan ${{ env.image_name_gitea }}:${{ env.image_tag }} + $(date +"%Y-%m-%d %T") + Trivy-Image-Scan of: ${{ env.image_name_gitea }}:${{ env.image_tag }} + \" + }"