Home

Awesome

🚀 Telegram for GitHub Actions

繁體中文 | 简体中文

GitHub Action for sending Telegram notification messages.

notification

Actions Status

Usage

Note: If you receive the "Error: Chat not found" error, please refer to this StackOverflow answer here.

Send a custom message and view the custom variables below.

name: telegram message
on: [push]
jobs:

  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: send telegram message on push
        uses: appleboy/telegram-action@master
        with:
          to: ${{ secrets.TELEGRAM_TO }}
          token: ${{ secrets.TELEGRAM_TOKEN }}
          message: |
            ${{ github.actor }} created commit:
            Commit message: ${{ github.event.commits[0].message }}
            
            Repository: ${{ github.repository }}
            
            See changes: https://github.com/${{ github.repository }}/commit/${{github.sha}}

Remove args to send the default message.

- name: send default message
  uses: appleboy/telegram-action@master
  with:
    to: ${{ secrets.TELEGRAM_TO }}
    token: ${{ secrets.TELEGRAM_TOKEN }}

workflow

Input variables

VariableDescription
socks5optional. Support socks5 proxy URL
photooptional. Photo message
documentoptional. Document message
stickeroptional. Sticker message
audiooptional. Audio message
voiceoptional. Voice message
locationoptional. Location message
venueoptional. Venue message
videooptional. Video message
debugoptional. Enable debug mode
formatoptional. markdown or html. See MarkdownV2 style
messageoptional. Custom message
message_fileoptional. Overwrite the default message template with the contents of the specified file.
disable_web_page_previewoptional. Disables link previews for links in this message. Default is false.
disable_notificationoptional. Disables notifications for this message, supports sending a message without notification. Default is false.

Example

Send photo message:

- uses: actions/checkout@master
- name: send photo message
  uses: appleboy/telegram-action@master
  with:
    to: ${{ secrets.TELEGRAM_TO }}
    token: ${{ secrets.TELEGRAM_TOKEN }}
    message: send photo message
    photo: tests/github.png
    document: tests/gophercolor.png

Send location message:

- name: send location message
  uses: appleboy/telegram-action@master
  with:
    to: ${{ secrets.TELEGRAM_TO }}
    token: ${{ secrets.TELEGRAM_TOKEN }}
    location: '24.9163213 121.1424972'
    venue: '35.661777 139.704051 竹北體育館 新竹縣竹北市'

Send message using custom proxy (support http, https, and socks5) like socks5://127.0.0.1:1080 or http://222.124.154.19:23500

- name: send message using socks5 proxy URL
  uses: appleboy/telegram-action@master
  with:
    to: ${{ secrets.TELEGRAM_TO }}
    token: ${{ secrets.TELEGRAM_TOKEN }}
    socks5: "http://222.124.154.19:23500"
    message: Send message from socks5 proxy URL.

Secrets

Getting started with Telegram Bot API.

How to get unique identifier from telegram api:

curl https://api.telegram.org/bot<token>/getUpdates

See the result: (get chat id like 65382999)

{
  "ok": true,
  "result": [
    {
      "update_id": 664568113,
      "message": {
        "message_id": 8423,
        "from": {
          "id": 65382999,
          "is_bot": false,
          "first_name": "Bo-Yi",
          "last_name": "Wu (appleboy)",
          "username": "appleboy46",
          "language_code": "en"
        },
        "chat": {
          "id": 65382999,
          "first_name": "Bo-Yi",
          "last_name": "Wu (appleboy)",
          "username": "appleboy46",
          "type": "private"
        },
        "date": 1550333434,
        "text": "?"
      }
    }
  ]
}

Template variable

Github VariableTelegram Template Variable
GITHUB_REPOSITORYrepo
GITHUB_ACTORrepo.namespace
GITHUB_SHAcommit.sha
GITHUB_REFcommit.ref
GITHUB_WORKFLOWgithub.workflow
GITHUB_ACTIONgithub.action
GITHUB_EVENT_NAMEgithub.event.name
GITHUB_EVENT_PATHgithub.event.path
GITHUB_WORKSPACEgithub.workspace