Отправить сообщение в Telegram #1
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: ubuntu-latest | |
steps: | |
- name: Проверить релиз | |
id: check_release | |
run: echo "exists=false" # Здесь должна быть ваша логика проверки релиза | |
- name: Получить версию | |
id: get_version | |
run: echo "::set-output name=VERSION::1.0.0" # Здесь должна быть ваша логика получения версии | |
- name: Отправить сообщение в Telegram | |
if: steps.check_release.outputs.exists == 'false' && github.event.inputs.release == 'true' | |
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: | | |
pwsh -Command " | |
$telegramBotToken = '${{ secrets.TELEGRAM_BOT_TOKEN }}' | |
$telegramChatId = '${{ secrets.TELEGRAM_CHAT_ID }}' | |
$releaseUrl = 'https://github.com/${{ github.repository }}/releases/tag/${{ steps.get_version.outputs.VERSION }}' | |
$message = 'Новый релиз: ${{ github.event.inputs.namevers }}`nВерсия: ${{ steps.get_version.outputs.VERSION }}`nОписание: ${{ github.event.inputs.descr }}`nSolution Name: ${{ env.Solution_Name }}`nСсылка на релиз: $releaseUrl' | |
$uri = 'https://api.telegram.org/bot' + $telegramBotToken + '/sendMessage' | |
$body = @{ | |
chat_id = $telegramChatId | |
text = $message | |
} | |
Invoke-RestMethod -Uri $uri -Method Post -Body $body | |
" |