This is GitHub Action to send messages or files to Telegram using official
Telegram Bot API.
TL;DR - Bot token and chat ID required.
- First of all, you need to create (or take already existed if you have)
Telegram
Bot. You need to go to
@BotFather
bot in Telegram to create one. Just follow bot instructions.
After creating a bot, you need to write down bot token. You can find token of all your bot with@BotFather
bot. - Next, you need to create Telegram channel (can be private) and add your bot
to it.
You need to grant at least
Post messages
permission. - After creating channel, you need to get channel ID. You can do it
with
@username_to_id_bot
(Not official Telegram bot). - Now you have both bot token and channel ID. Add these variables to
Github Secrets.
It's strictly not recommended to use raw values in your pipeline, please consider using Secrets! - Now, you're ready to go! Go to Examples section for some inspiration!
- Send simple message
on: [ push ] jobs: tg_post_job: runs-on: ubuntu-latest name: A job to post data in tg steps: - name: Send data uses: BorisTestov/tg_sender_action@latest env: TG_SENDER_TG_CHAT_ID: ${{ secrets.TG_SENDER_TG_CHAT_ID }} TG_SENDER_TG_BOT_TOKEN: ${{ secrets.TG_SENDER_TG_BOT_TOKEN }} TG_SENDER_PAYLOAD_MESSAGE: "Hello World!"
- Send file
on: [ push ] jobs: tg_post_job: runs-on: ubuntu-latest name: A job to post data in tg steps: - name: Send data uses: BorisTestov/tg_sender_action@latest env: TG_SENDER_TG_CHAT_ID: ${{ secrets.TG_SENDER_TG_CHAT_ID }} TG_SENDER_TG_BOT_TOKEN: ${{ secrets.TG_SENDER_TG_BOT_TOKEN }} TG_SENDER_PAYLOAD_FILE_PATH: /path/to/file
- Send file with caption
on: [ push ] jobs: tg_post_job: runs-on: ubuntu-latest name: A job to post data in tg steps: - name: Send data uses: BorisTestov/tg_sender_action@latest env: TG_SENDER_TG_CHAT_ID: ${{ secrets.TG_SENDER_TG_CHAT_ID }} TG_SENDER_TG_BOT_TOKEN: ${{ secrets.TG_SENDER_TG_BOT_TOKEN }} TG_SENDER_PAYLOAD_MESSAGE: "Hello World!" TG_SENDER_PAYLOAD_FILE_PATH: /path/to/file
- Send nothing (Doesn't trigger error but do nothing)
on: [ push ] jobs: tg_post_job: runs-on: ubuntu-latest name: A job to post data in tg steps: - name: Send data uses: BorisTestov/tg_sender_action@latest env: TG_SENDER_TG_CHAT_ID: ${{ secrets.TG_SENDER_TG_CHAT_ID }} TG_SENDER_TG_BOT_TOKEN: ${{ secrets.TG_SENDER_TG_BOT_TOKEN }}
TG_SENDER_TG_BOT_TOKEN
- Bot token. Required.TG_SENDER_TG_CHAT_ID
- ID of the chat to send data to. Required.TG_SENDER_PAYLOAD_FILE_PATH
- Path to file to send. Optional.TG_SENDER_PAYLOAD_MESSAGE
- Message to send. Optional.TG_SENDER_LOG_LEVEL
- Log level. Optional. Default isINFO
.TG_SENDER_LOG_FORMAT
- Message format. Optional. Default is%(asctime)s,%(msecs)03d %(levelname)-8s %(name)s: %(message)s
.TG_SENDER_LOG_DATEFMT
- Date format. Optional. Default is%b-%d-%Y %H:%M:%S
Licensed under the MIT license. See LICENSE for more information.