Skip to content

Instantly share code, notes, and snippets.

@syossan27
Last active August 7, 2021 12:07
Show Gist options
  • Save syossan27/ce981b738921b682d0d658899fea6f69 to your computer and use it in GitHub Desktop.
Save syossan27/ce981b738921b682d0d658899fea6f69 to your computer and use it in GitHub Desktop.
name: "Notice of need review PR"
on:
schedule:
- cron: "0 10,17 * * 1-5" # 月〜金の10時, 17時に実行
jobs:
notice:
runs-on: ubuntu-latest
steps:
- name: Search requested review PR
uses: actions/github-script@v4
id: message
with:
github-token: ${{secrets.GITHUB_TOKEN}}
result-encoding: string
script: |
# Pull Requestの一覧を取得
const result = await github.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo
})
const pulls = result.data
pulls_count = 0
message = ""
# 取得した一覧からSlackに流すメッセージを構築
for (const pull of pulls) {
# DraftのPR、[WIP]とタイトルについたPRは流さないようにする
if (pull.draft || pull.title.match(/[WIP]/)) {
continue
}
# 表示するPR毎に改行
if (pulls_count != 0) {
message += "\\n"
}
message += " - \<" + pull.html_url + "\|" + pull.title + "\>"
pulls_count++
}
return message
- name: Post to slack
id: slack
uses: slackapi/[email protected]
with:
# Slack Payload: https://api.slack.com/reference/messaging/payload
payload: "{\"text\":\"${{ steps.message.outputs.result }}\", \"username\":\"レビュー待ちのPR列挙くん\", \"icon_emoji\":\":robot_face:\"}"
env:
# GitHub RepositoryのSecretにIncoming WebhookのURLを登録しておこう
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment