문의하기 구글 스프레드시트 API 요청 책임을 클라이언트에서 서버로 변경 #329
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: PR Slack Notification | |
on: | |
pull_request: | |
types: [opened, reopened] | |
jobs: | |
notify_reviewers: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 변수 추출 | |
run: | | |
SLACK_WEBHOOK_URL=${{ secrets.SLACK_PR_CREATE_WEBHOOK_URL }} | |
SLACK_IDS=${{ secrets.SLACK_IDS }} | |
echo "SLACK_WEBHOOK_URL=$SLACK_WEBHOOK_URL" >> $GITHUB_ENV | |
echo "SLACK_IDS=$SLACK_IDS" >> $GITHUB_ENV | |
- name: PR 생성 시 reviewer들에게 Slack 알람 보내기 | |
run: | | |
PR_TITLE="${{ github.event.pull_request.title }}" | |
PR_URL="${{ github.event.pull_request.html_url }}" | |
REVIEWERS='${{ toJson(github.event.pull_request.requested_reviewers.*.login) }}' | |
echo "REVIEWERS: $REVIEWERS" | |
parse_slack_ids() { | |
echo "$SLACK_IDS" | jq -r 'to_entries | map("\(.key):\(.value)") | .[]' | |
} | |
reviewers=$(echo "$REVIEWERS" | jq -r '.[]') | |
mentions="" | |
for reviewer in $reviewers; do | |
slack_id=$(parse_slack_ids | grep "^$reviewer:" | cut -d':' -f2) | |
if [ -n "$slack_id" ]; then | |
mentions="$mentions <@$slack_id>" | |
else | |
mentions="$mentions $reviewer" | |
fi | |
done | |
echo "Mentions: $mentions" | |
if [ ! -z "$mentions" ]; then | |
message="$mentions 님, 새로운 PR이 생성되었습니다: <$PR_URL|$PR_TITLE>" | |
curl -X POST -H 'Content-type: application/json' \ | |
--data "{\"text\":\"$message\"}" \ | |
"$SLACK_WEBHOOK_URL" | |
echo "Sent message: $message" | |
else | |
echo "No reviewers to notify" | |
fi | |