Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions .github/workflows/common-slack-notify-opened.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Slack Notification (Opened/Ready)

on:
pull_request:
types: [opened, ready_for_review]
types: [ opened, ready_for_review ]

permissions: {}
permissions: { }

concurrency:
group: pr-${{ github.event.pull_request.number }}-slack-opened-ready
Expand All @@ -28,6 +28,8 @@ jobs:
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
REVIEWERS_JSON: ${{ toJson(github.event.pull_request.requested_reviewers) }}
run: |
REPO_NAME="${GITHUB_REPOSITORY#*/}"

declare -A GITHUB_TO_SLACK
GITHUB_TO_SLACK["soeun2537"]="U09A0LM0CRW"
GITHUB_TO_SLACK["taek2222"]="U099ARRH3D3"
Expand Down Expand Up @@ -56,7 +58,20 @@ jobs:
echo "리뷰어가 없으므로 알림 생략"
exit 0
fi

curl -X POST -H 'Content-type: application/json' \
--data "{\"text\": \"🔥 *리뷰 요청 알림*\n*PR 제목:* ${PR_TITLE} (#${PR_NUMBER})\n*작성자:* ${SLACK_AUTHOR_MENTION}\n*리뷰어:* ${REVIEWER_MENTIONS}\n*링크:* ${PR_URL}\"}" \
$SLACK_WEBHOOK_URL

PAYLOAD=$(jq -n \
--arg repo "$REPO_NAME" \
--arg title "$PR_TITLE" \
--arg number "$PR_NUMBER" \
--arg author "$SLACK_AUTHOR_MENTION" \
--arg reviewers "$REVIEWER_MENTIONS" \
--arg url "$PR_URL" \
'{
text: "🔥 (\($repo)) 리뷰 요청 알림",
blocks: [
{type: "header", text: {type: "plain_text", text: "🔥 (\($repo)) 리뷰 요청 알림", emoji: true}},
{type: "section", text: {type: "mrkdwn", text: "*PR 제목:* \($title) (#\($number))\n*작성자:* \($author)\n*리뷰어:* \($reviewers)\n*링크:* \($url)"}}
]
}')

curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL
27 changes: 21 additions & 6 deletions .github/workflows/common-slack-notify-rerequested.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Slack Notification (Review Requested)

on:
pull_request:
types: [review_requested]
types: [ review_requested ]

permissions:
contents: read
Expand Down Expand Up @@ -32,6 +32,8 @@ jobs:
PR_REVIEWER: ${{ github.event.requested_reviewer.login }}
REPOSITORY: ${{ github.repository }}
run: |
REPO_NAME="${GITHUB_REPOSITORY#*/}"

declare -A GITHUB_TO_SLACK
GITHUB_TO_SLACK["soeun2537"]="U09A0LM0CRW"
GITHUB_TO_SLACK["taek2222"]="U099ARRH3D3"
Expand Down Expand Up @@ -59,15 +61,28 @@ jobs:
echo "매핑 없는 사용자(${PR_REVIEWER})는 생략"
exit 0
fi

if [[ -n "${GITHUB_TO_SLACK[$PR_AUTHOR]}" ]]; then
SLACK_AUTHOR_MENTION="<@${GITHUB_TO_SLACK[$PR_AUTHOR]}>"
else
SLACK_AUTHOR_MENTION="@${PR_AUTHOR}" # 평문
fi

SLACK_REVIEWER_MENTION="<@$slack_id>"

curl -X POST -H 'Content-type: application/json' \
--data "{\"text\": \"🏸 *재리뷰 요청 알림*\n*PR 제목:* ${PR_TITLE} (#${PR_NUMBER})\n*작성자:* ${SLACK_AUTHOR_MENTION}\n*리뷰어:* ${SLACK_REVIEWER_MENTION}\n*링크:* ${PR_URL}\"}" \
$SLACK_WEBHOOK_URL

PAYLOAD=$(jq -n \
--arg repo "$REPO_NAME" \
--arg title "$PR_TITLE" \
--arg number "$PR_NUMBER" \
--arg author "$SLACK_AUTHOR_MENTION" \
--arg reviewer "$SLACK_REVIEWER_MENTION" \
--arg url "$PR_URL" \
'{
text: "🏸 (\($repo)) 재리뷰 요청 알림",
blocks: [
{type: "header", text: {type: "plain_text", text: "🏸 (\($repo)) 재리뷰 요청 알림", emoji: true}},
{type: "section", text: {type: "mrkdwn", text: "*PR 제목:* \($title) (#\($number))\n*작성자:* \($author)\n*리뷰어:* \($reviewer)\n*링크:* \($url)"}}
]
}')

curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL
31 changes: 25 additions & 6 deletions .github/workflows/common-slack-notify-submitted.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ name: Slack Notification (Submitted)

on:
pull_request_review:
types: [submitted]
types: [ submitted ]

permissions: {}
permissions: { }

concurrency:
group: pr-${{ github.event.pull_request.number }}-slack-submitted
Expand All @@ -15,6 +15,9 @@ jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq

- name: Notify Review Submitted
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
Expand All @@ -29,6 +32,8 @@ jobs:
echo "단순 코멘트 리뷰는 알림 생략"
exit 0
fi

REPO_NAME="${GITHUB_REPOSITORY#*/}"

declare -A GITHUB_TO_SLACK
GITHUB_TO_SLACK["soeun2537"]="U09A0LM0CRW"
Expand All @@ -54,7 +59,21 @@ jobs:
approved) ICON="✅" ;;
changes_requested) ICON="🔴" ;;
esac

curl -X POST -H 'Content-type: application/json' \
--data "{\"text\": \"${ICON} *리뷰 완료 알림*\n*PR 제목:* ${PR_TITLE} (#${PR_NUMBER})\n*작성자:* ${SLACK_AUTHOR_MENTION}\n*상태:* ${REVIEW_STATE}\n*링크:* ${PR_URL}\"}" \
$SLACK_WEBHOOK_URL

PAYLOAD=$(jq -n \
--arg icon "$ICON" \
--arg repo "$REPO_NAME" \
--arg title "$PR_TITLE" \
--arg number "$PR_NUMBER" \
--arg author "$SLACK_AUTHOR_MENTION" \
--arg state "$REVIEW_STATE" \
--arg url "$PR_URL" \
'{
text: "\($icon) (\($repo)) 리뷰 완료 알림",
blocks: [
{type: "header", text: {type: "plain_text", text: "\($icon) (\($repo)) 리뷰 완료 알림", emoji: true}},
{type: "section", text: {type: "mrkdwn", text: "*PR 제목:* \($title) (#\($number))\n*작성자:* \($author)\n*상태:* \($state)\n*링크:* \($url)"}}
]
}')

curl -X POST -H 'Content-type: application/json' --data "$PAYLOAD" $SLACK_WEBHOOK_URL