Отправить сообщение в Telegram #17
This file contains 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: Отправить сообщение в Telegram | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
send_telegram_message: | |
runs-on: windows-latest | |
steps: | |
- name: Получить версию | |
id: get_version | |
run: echo "::set-output name=VERSION::xxxx" # Версия всегда "xxxx" | |
- name: Отправить сообщение в Telegram | |
env: | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
RELEASE_URL: https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.VERSION }} | |
run: | | |
$telegramBotToken = '${{ secrets.TELEGRAM_BOT_TOKEN }}' | |
$telegramChatId = '${{ secrets.TELEGRAM_CHAT_ID }}' | |
$releaseUrl = 'https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.VERSION }}' | |
$message = 'Новый релиз: СтатичноеНазваниеРелиза`nВерсия: xxxx`nОписание: СтатичноеОписание`nSolution Name: СтатичноеНазваниеРешения`nСсылка на релиз: $releaseUrl' | |
$uri = 'https://api.telegram.org/bot' + $telegramBotToken + '/sendMessage' | |
$body = @{ | |
chat_id = $telegramChatId | |
text = $message | |
} | |
$bodyJson = $body | ConvertTo-Json -Compress | |
Invoke-RestMethod -Uri $uri -Method Post -Body $bodyJson -ContentType 'application/json' | |
- name: Отправить сообщение в Telegram 2 | |
env: | |
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }} | |
TELEGRAM_CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} | |
RELEASE_URL: https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.VERSION }} | |
run: | | |
$telegramBotToken = '${{ secrets.TELEGRAM_BOT_TOKEN }}' | |
$telegramChatId = '${{ secrets.TELEGRAM_CHAT_ID }}' | |
$releaseUrl = 'https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.VERSION }}' | |
$message = "<b>🎉 Новый релиз:</b> ${{ github.event.inputs.namevers }}\n<b>📦 Версия:</b> ${{ steps.get_version.outputs.VERSION }}\n<b>📝 Описание:</b> ${{ github.event.inputs.descr }}\n<b>🔧 Solution Name:</b> ${{ env.Solution_Name }}\n<b>🔗 Ссылка на релиз:</b> <a href='$releaseUrl'>$releaseUrl</a>" | |
$uri = 'https://api.telegram.org/bot' + $telegramBotToken + '/sendMessage' | |
$body = @{ | |
chat_id = $telegramChatId | |
text = $message | |
parse_mode = 'HTML' | |
} | |
$bodyJson = $body | ConvertTo-Json -Compress | |
Invoke-RestMethod -Uri $uri -Method Post -Body $bodyJson -ContentType 'application/json' | |