skip to Main Content

I’m trying to use Github Actions to send a Telegram message every time someone pushes to the master of repo. But using this action causes the following error and action fails:

missing telegram token or user list

Here is my yml file:

name: CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Telegram Notify
        uses: appleboy/[email protected]
        with:
          to: ${{ secrets.TELEGRAM_CHAT_ID }}
          token: ${{ secrets.TELEGRAM_TOKEN }}
          message: |
            An event occured in ${{ github.repository    }} repository.
            ${{ github.event_name }}

I quite new in Github Actions. What should I do to fix this?

P.S: I’ve added telegram_token and telegram_chat_id to secrets section of repo.

2

Answers


  1. Go to the repo settings and set the secrets for the TELEGRAM_CHAT_ID and the TELEGRAM_TOKEN. when setting the secrets for TELEGRAM_TOKEN make sure to send the queries to the Telegram Bot API using the bot token https://api.telegram.org/bot/METHOD_NAME, for example https://api.telegram.org/bot19023205:BNF-23dred1234ghIkl-dre4fdgr8nv1w4od/getMe

    Login or Signup to reply.
  2. Just in case, who got error "missing telegram token or user list" on "appleboy/telegram-action" when using reusability workflow (or workflow_call), may this help.

    If you are using workflow reusability to use send telegram notif,
    for example:

    # .github/workflows/send-telegram.yml
    name: Send Telegram Notification
    
    on: [workflow_call]
    jobs:
      send-notif:
        name: Send Telegram Notification
        runs-on: ubuntu-latest
        steps:
          - name: send telegram message on push
            uses: appleboy/telegram-action@master
            with:
              to: ${{ secrets.TELEGRAM_CHAT_ID }}
              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}}
    

    secrets wont get passed directly to here!

    you need to pass it on your caller like this

    # .github/workflows/testing-tele-notif.yml
    name: Testing telegram notification
    
    on:
      push:
        branches: [test/telegram-notif]
      pull_request:
        branches: [test/telegram-notif]
    
    jobs:
      send-notif-on-success:
        uses: ./.github/workflows/send-telegram.yml
        secrets: inherit # MUST PUT THIS!
    
      send-notif-on-failure:
        uses: ./.github/workflows/send-telegram.yml
        secrets: inherit # MUST PUT THIS!
    

    Hence, on your workflow_call will use the secrets provided by the caller.

    I hope somene who stumble on the same problem

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search