6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

notificationをdiscordで受ける

Posted at

本日 9/12(土) に isucon10 の予選に参加をしました。
最近のisuconはdiscordを連絡手段に使われることが多いので、チームのコミュニケーションも discord に今回は集約をしました。
そんな中やっぱり deploy の notification も slackじゃなく discord で受けたいなーと思い、botとか作れないのかなと調べたんですが、
すごく簡単にできたので、備忘録がてら残しておきます。

discord で Webhook を作成する

  1. discord の サーバの設定を開く
  2. メニューにある「連携サービス」を押下する
  3. 「新しいウェブフック」ボタンを押下する
  4. 名前とアイコンを適当に設定をし、発言させたいチャンネルを選ぶ (ここでは #deploy を選択をしてます)
  5. 「ウェブフックURLをコピー」ボタンを押下する

curl で メッセージを送ってみる

curl -H "Content-Type: application/json" -X POST -d '{"username": "bot", "content": "@everyone デプロイできたで〜\(^o^)/"}'  <<上記でコピーしたウェブフックURL>>

以上でメッセージを送る事ができる。かんたん。

今回は以下のような簡易的なスクリプトを書いてデプロイをしていました。

# ! /bin/bash -x

notify_discord () {
    curl -H "Content-Type: application/json" -X POST -d '{"username": "bot", "content": "@everyone デプロイできたで〜\(^o^)/"}'  <<上記でコピーしたウェブフックURL>>
}


echo "start deploy ${USER}"

ssh isucon-server-1 "cd isuumo/webapp; git pull"
ssh isucon-server-2 "cd isuumo/webapp; git pull"
ssh isucon-server-3 "cd isuumo/webapp; git pull"

echo "finish deploy ${USER}"

notify_discord
6
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?