プルリクエストが発生すると電報で通知される

2500 ワード

電報は、開発者フレンドリーな機能の多くのクールメッセージングプラットフォームです.私は、私のgithub公共のリポジトリにプル要求が上がるたびに、私が通知を受けることができるかどうか疑問に思いました.

Gitハブアクションの活用


GitHub Actionsは、あなたのgithubリポジトリのすべての種類のオートメーションをするのに用いられることができます.
迅速にいくつかのGoogle検索を行うと、私はプルリクエストが発生したときに電報の通知を送信するために使用できるアクションを見つけた.

新しいワークフローを作成する


あなたの倉庫ホームページの下で
  • 、新しいワークフロー
  • を作成してください
  • 選択した単純なワークフローを選択します.

    # This is a basic workflow to help you get started with Actions
    
    name: Telegram notification
    
    # Controls when the action will run. Triggers the workflow on pull request
    on:
      pull_request:
        branches: [ develop ]
    
    # A workflow run is made up of one or more jobs that can run sequentially or in parallel
    jobs:
      # This workflow contains a single job called "build"
      build:
        # The type of runner that the job will run on
        runs-on: ubuntu-latest
    
        # Steps represent a sequence of tasks that will be executed as part of the job
        steps:
          # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
          - uses: actions/checkout@v2
    
          # Runs the telegram notify action to send a notification
          - name: Telegram Notify
            uses: appleboy/telegram-action@master
            with:
              to: ${{ secrets.TELEGRAM_TO }}
              token: ${{ secrets.TELEGRAM_TOKEN }}
              format: markdown
              message: |
                A new PR is raised [View all PR's](https://github.com/<user>/<repo>/pulls)
    

    電報ボットトークンとグループユニークIDを取得

  • は新しいボットを作成するためにTelegram Bot Fatherを使用します.
  • ボットが作成されるとトークンを返し、保存します.
  • は、電報グループを作成し、グループにこのボットを追加します.
  • このグループにテストメッセージを追加します.
  • グループのユニークなIDを得るために、
  • .
  • https://api.telegram.org/bot<token>/getUpdates
  • は、chat.idの下でグループユニークなIDを見つけます
  • ワークフローに必要な秘密を作成する

  • リポジトリ
  • の下の設定に移動しますsecretsの下の

  • は、上からトークン値でTELEGRAM_TOKENと呼ばれている新しい秘密を作成します.
  • グループのユニークなIDでTELEGRAM_TOと呼ばれる新しい秘密を作成します.
  • おっと!プルリクエストが発生すると、グループに通知が送信されます.

    アップル / 電報行為


    電報を送るgithubアクション。