🔔

GitHub Actions から各プラットフォームへの通知方法まとめ

2022/12/15に公開

方針

公式アクションや公式アプリがあれば優先。
ない場合はサードパーティアクションや Webhook。

サードパーティアクションは Docker アクション(Linux でしか使えない)と Node.js 12 な(古い) JavaScript アクションを除外。
また、特定のイベントに依存せずテキストがフリー入力できるもの。(イベントのペイロードを自動でいい感じに整形してくれるのは便利なんですが汎用性が低いので)

より良いものや追記してほしいプラットフォームがあれば教えてください。

GitHub

GitHub CLI

https://cli.github.com/

GitHub API のラッパーコマンドです。
プリインストールされています。

.github/workflows/notify.yml
steps:
  - run: gh pr comment ${number} --body "@${GITHUB_ACTOR} Completed"
    env:
      GH_TOKEN: ${{ github.token }}
      GH_REPO: ${{ github.repository }}
      number: ${{ github.event.number }}
    if: ${{ always() }}

Slack

公式アクション

https://github.com/slackapi/slack-github-action

3 種類の方法に対応しています。

  • ワークフロービルダー
  • アプリ (API)
  • Incoming Webhook
.github/workflows/notify.yml (API)
steps:
  - uses: slackapi/slack-github-action@v1.23.0
    with:
      channel-id: "CHANNEL_ID"
      payload: |
        {
          "text": "Completed"
        }
    env:
      SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
    if: ${{ always() }}

公式アプリ

https://slack.github.com/

.com だけでなく GHEC でも使えるようです。
GHES 3.6 はプライベートベータ中で GHES 3.8 で GA 予定。

Microsoft Teams

公式アプリ

https://github.blog/2020-09-10-announcing-the-github-integration-with-microsoft-teams/

サードパーティアクション

いくつかあるようですが Docker アクションや Node.js 12 な JavaScript アクションが多く、これといったものが見つかりませんでした。

https://github.com/marketplace?type=actions&query=microsoft+teams

Yammer

API

https://learn.microsoft.com/ja-jp/rest/api/yammer/rest-api-rate-limits

サードパーティアクション

残念ながら現時点では 1 つもないようです…

https://github.com/marketplace?type=actions&query=yammer

Chatwork

サードパーティアクション

https://github.com/okuzawats/chatwork-messaging-action

.github/workflows/notify.yml
steps:
  - uses: okuzawats/chatwork-messaging-action@v1.0
    with:
      apiToken: ${{ secrets.CHATWORK_API_TOKEN }}
      roomId: ${{ secrets.CHATWORK_ROOM_ID }}
      message: Completed
    if: ${{ always() }}

Marketplace から適当に選びました。

Discord

Webhook

https://discord.com/developers/docs/resources/webhook#execute-githubcompatible-webhook

サードパーティアクション

https://github.com/stegzilla/discord-notify

.github/workflows/notify.yml
steps:
  - uses: stegzilla/discord-notify@v2
    with:
      webhook_url: ${{ secrets.DISCORD_WEBHOOK_URL }}
      title: Completed
      message: Completed
    if: ${{ always() }}

Marketplace から適当に選びました。

Twitter

サードパーティアクション

https://github.com/snow-actions/tweet

.github/workflows/notify.yml
steps:
  - uses: snow-actions/tweet@v1.4.0
    with:
      status: |
        Completed
    env:
      CONSUMER_API_KEY: ${{ secrets.TWITTER_CONSUMER_API_KEY }}
      CONSUMER_API_SECRET_KEY: ${{ secrets.TWITTER_CONSUMER_API_SECRET_KEY }}
      ACCESS_TOKEN: ${{ secrets.TWITTER_ACCESS_TOKEN }}
      ACCESS_TOKEN_SECRET: ${{ secrets.TWITTER_ACCESS_TOKEN_SECRET }}
    if: ${{ always() }}

詳細はこちら。

https://zenn.dev/snowcait/articles/514254f40e356d78c144

LINE

サードパーティアクション

数はたくさんあるようですが Docker アクションや Node.js 12 な JavaScript アクションが多く、これといったものが見つかりませんでした。

https://github.com/marketplace?type=actions&query=line

Nostr

サードパーティアクション

https://github.com/snow-actions/nostr

.github/workflows/notify.yml
steps:
  - uses: snow-actions/nostr@v1.0.0
    with:
      relay: ${{ vars.NOSTR_RELAY }}
      private-key: ${{ secrets.NOSTR_PRIVATE_KEY }}
      content: |
        Completed
    if: ${{ always() }}

Discussion