Skip to content
Closed
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
78 changes: 78 additions & 0 deletions .github/workflows/pr_revier_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
on:
pull_request:
types: [review_requested]

jobs:
notify:
runs-on: ubuntu-latest

steps:
- name: Wait for reviewers to settle
run: sleep 10

- name: Check if notification already sent
id: check
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "🔍 Checking for existing notification comment..."
pr_number="${{ github.event.pull_request.number }}"
comment_count=$(gh pr view "$pr_number" --json comments \
| jq '[.comments[].body | select(. | contains("[discord-review-notified]"))] | length')

if [ "$comment_count" -gt 0 ]; then
echo "skip=true" >> "$GITHUB_OUTPUT"
echo "✅ Notification already sent for PR #$pr_number"
else
echo "skip=false" >> "$GITHUB_OUTPUT"
echo "✅ No notification sent yet for PR #$pr_number"
fi

- name: Get unique reviewers
id: reviewers
if: steps.check.outputs.skip == 'false'
env:
REVIEWERS_JSON: ${{ toJson(github.event.pull_request.requested_reviewers) }}
run: |
reviewers=$(echo "$REVIEWERS_JSON" | jq -r '.[].login' | sort | uniq | paste -sd "," -)
echo "reviewers=$reviewers" >> "$GITHUB_OUTPUT"

- name: Map to Discord IDs
id: map
if: steps.check.outputs.skip == 'false'
run: |
declare -A USER_MAP=(
["laggu"]="1269619098405441537"
["rlooo"]="1060181420389187715"
["yuchem2"]="307875691074945024"
)

mentions=""

IFS="," read -ra reviewers <<< "${{ steps.reviewers.outputs.reviewers }}"
for login in "${reviewers[@]}"; do
id=${USER_MAP[$login]}
[ -n "$id" ] && mentions+="<@$id> "
done

echo "mentions=$mentions" >> "$GITHUB_OUTPUT"

- name: Send Discord Notification
if: steps.check.outputs.skip == 'false'
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
MENTIONS: ${{ steps.map.outputs.mentions }}
PR_URL: ${{ github.event.pull_request.html_url }}
run: |
curl -X POST -H "Content-Type: application/json" \
-d "{
\"content\": \"📣 $MENTIONS님! Pull Request 리뷰어로 지정됐습니다.\\n🔗 PR: $PR_URL\"
}" \
"$DISCORD_WEBHOOK_URL"

- name: Mark notification sent
if: steps.check.outputs.skip == 'false'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr comment ${{ github.event.pull_request.number }} --body "[discord-review-notified] 리뷰 알림 전송됨 ✅"
Loading