0%

Instant telegram notification if GitHub is Stared

I really like the sense of achievement obtained by open source projects. In the past year, I have insisted on doing several open source projects, and I have also gained some stars from netizens, some also add WeChat, raise requirements, the charm of open source is here.

For example, if someone stars your project, it would be better to be able to receive telegram notifications in time, because the NPM package release notification has been done before, so this is easy to do, but because there are still some pitfalls, so mark here, maybe help some friends.

Configuration

1
2
3
4
5
6
7
8
9
10
env:
REPO_NAME: ${{ github.event.repository.name }}
steps:
- name: Notify
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: Someone stars **${{env.REPO_NAME}}** repository, see [here](https://github.com/${{github.repository}}).
format: markdown

Full Configuration click here

Configuration Instructions

GitHub Action中的变量有很多中,${{ github.event.repository.name }}${{github.repository}}为上下文环境变量,这个不需要配置,直接使用,${{ secrets.TELEGRAM_TO }}为仓库配置变量,需要在仓库设置中设定。

There are many variables in GitHub Action, ${{ github.event.repository.name }}, ${{github.repository}} are context variables, which do not need to be configured, use directly, ${ { secrets.TELEGRAM_TO }} is a warehouse configuration variable, which needs to be set in the warehouse settings.

GITHUB_SERVER_URL is not Worked?

The official website has said that the default environment variable is $GITHUB_SERVER_URL, and the usage method is $GITHUB_SERVER_URL, but if it is written in the above message, it will not work, the reason is that the environment variable is used when using the shell, if it is a job The github context needs to be used in the step

Telegram Configuration Parameter Acquisition

  • TELEGRAM_TOKEN
    • Through @BotFather, create a Bot to obtain, note that the complete format of the Token will be like this 12345678:BBFntuCD6nRx1ZIYZ-eCyfP1UO4FeAjnz2M
  • TELEGRAM_TO
    • Need to send a message to the bot, make sure chat is turned on

    • Visit https://api.telegram.org/bot$TELEGRAM_TOKEN/getUpdates to get the chatID in it

Write at the End

As above, you can realize the telegram notification, start!