diff --git a/.github/workflows/tg_notify.yml b/.github/workflows/tg_notify.yml index aef7ec0..8e3dc9a 100644 --- a/.github/workflows/tg_notify.yml +++ b/.github/workflows/tg_notify.yml @@ -11,19 +11,37 @@ on: types: [submitted] jobs: - build: - name: Build + notify: runs-on: ubuntu-latest steps: - - name: send telegram message on push + - name: Create message file + run: | + TITLE="${{ github.event.issue.title || github.event.pull_request.title || 'Комментарий' }}" + COMMENT="${{ github.event.comment.body || '' }}" + MSG="Repository: ${{ github.repository }} +Type: ${{ github.event_name }} +Action: ${{ github.event.action }} +Title: ${TITLE} +${COMMENT} + +See: ${{ github.event.issue.html_url || github.event.pull_request.html_url || github.event.comment.html_url || github.event.review.html_url }}" + echo "$MSG" > message.txt + LENGTH=$(wc -c < message.txt) + echo "MESSAGE_LENGTH=$LENGTH" >> $GITHUB_ENV + + - name: Send full message if short + if: ${{ env.MESSAGE_LENGTH < 4096 }} uses: appleboy/telegram-action@master with: to: ${{ secrets.TELEGRAM_CHAT_ID }} token: ${{ secrets.TELEGRAM_BOT_TOKEN }} - message: | - Repository: ${{ github.repository }} - Type: ${{ github.event_name }} - Action: ${{ github.event.action }} - Titile: ${{ github.event.issue.title || github.event.pull_request.title || 'Комментарий' }} - ${{github.event.comment.body || ''}} - See ${{ github.event.issue.html_url || github.event.pull_request.html_url || github.event.comment.html_url || github.event.review.html_url }} + message_file: message.txt + + - name: Send only link if message too long + if: ${{ env.MESSAGE_LENGTH >= 4096 }} + uses: appleboy/telegram-action@master + with: + to: ${{ secrets.TELEGRAM_CHAT_ID }} + token: ${{ secrets.TELEGRAM_BOT_TOKEN }} + message: | + See: ${{ github.event.issue.html_url || github.event.pull_request.html_url || github.event.comment.html_url || github.event.review.html_url }}