DEV Community

Felipe Marques
Felipe Marques

Posted on • Updated on

Telegram notification with Github Actions

🇧🇷 Versão em português

Use the following script to receive Telegram notifications always your Github Actions is running.

    - name: Send Telegram Message Ok
        uses: appleboy/telegram-action@master
        env:
          GITHUB_CONTEXT: ${{ toJSON(github) }}
        with:
          to: ${{ secrets.TELEGRAM_ID }}
          token: ${{ secrets.TELEGRAM_TOKEN }}
          format: markdown
          message: |
            *1st line of your message with bold*
            *2nd line of your message with bold, too*
            Application: *Write something to be put inside your message*. The below lines still are part of your message.          
            Branch: *${{ github.ref }}*
            Repository: *${{ github.repository }}*
            Owner: *${{ github.repository_owner }}*
Enter fullscreen mode Exit fullscreen mode

If you want to go deeper into this component, go to project's github repository

As we can see, to use this component we need two important informations, the TELEGRAM_ID and the TELEGRAM_TOKEN.

To get your TELEGRAM_TOKEN, you will need to create a telegram's bot, do that starting a conversation with BotFather. Start a new conversation and search for @botfather.

BotFather

You can start the conversation sending a /help message to see all options allowed. But if you want to skip this step, just send /newbot and follow the instructions. When finish bot's creation, you will receive a message with your bot's token, as show below:
TELEGRAM_TOKEN

Good job! Now you got your TELEGRAM_TOKEN, in this example it is 2063069520:AAE7Gcummn9fSp_xLQH7dBGihpzOyWQCm9g.

Now, let's find out your TELEGRAM_ID. Just search for @userinfobot and start a conversation with /star message. The result message will be like that:

@your_telegram_username
Id: 12345678
First: <Your Firstname>
Last: <Your Lastname>
Lang: en-US
Enter fullscreen mode Exit fullscreen mode

Your TELEGRAM_ID is the number in second line, right between your username and firstname.

In this point you have all information to start sending notification messages at any pipeline in Github Actions.

Just add these information to repository secrets.

Top comments (3)

Collapse
 
thomasbnt profile image
Thomas Bnt ☕

Nice post, but why did you compress Telegram screenshots? 😵

Collapse
 
felipemsfg profile image
Felipe Marques

Thanks. I don't know what I did with screenshots lol

Collapse
 
thomasbnt profile image
Thomas Bnt ☕

😆😆😆