LoginSignup
0
0

More than 1 year has passed since last update.

⚡️Pull RequestをReady for reviewにしたときにslackに通知するGithub Actions

Posted at

最終的な成果物

コードサンプル

使用したworkflow: action-slack-notify

con:
  pull_request:
    types: [ready_for_review]
name: Slack Notification When PR become ready for review
jobs:
  slackNotification:
    name: Slack Notification
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2.2.0
    - name: Slack Notification
      uses: rtCamp/action-slack-notify@v2
      env:
        SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_FOR_PR_READY_FOR_REVIEW }} # あらかじめGithubのSettingにてSecretsを設定しておこう
        SLACK_LINK_NAMES: true # メッセージ内でのメンションを有効にする
        SLACK_MESSAGE: |
          レビューをお願いします🙏 @engineers
          <${{ github.event.pull_request.html_url }}|${{ github.event.pull_request.title }}>
        SLACK_USERNAME: 'レビューお願いします!Bot'
        MSG_MINIMAL: true # メッセージだけを通知文にする

やりたかったこと

Githubで、Pull RequestをReady for Reviewにした時にこれまではSlack上で「レビューお願いします!」と言っていたが、そのコストを削減したかった。

実装する中で気づいたこと

  • yml内で改行を反映するには|を用いれば、改行やスペースが反映されること(逆に反映されないのは>
  • Slack上でhyperlinkを作るには、markdown記法ではなく以下のように記述する必要があること
    • <link|text>
  • Pull RequestのGithubでのURLを取得するには
    • github.event.pull_request.html_url(string型)
  • Pull Requestのタイトルを取得するには
    • github.event.pull_request.title(string型)

ref: yamlの記法について
ref: プルリクエストにアクティビティが発生したときに発生するイベント

0
0
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
0
0