Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(*): PR 코멘트 스레드 기능 추가 #23

Closed
wants to merge 3 commits into from
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
59 changes: 31 additions & 28 deletions .github/workflows/slack-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@ jobs:
steps:
- name: Send Slack Notification for PR creation
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
uses: 8398a7/action-slack@v3
with:
status: custom
fields: author,pullRequest
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `Actor: ${process.env.AS_AUTHOR}
PR: ${process.env.AS_PULL_REQUEST}`,
}]
}
id: send_pr_notification
run: |
response=$(curl -X POST -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" -H "Content-type: application/json" \
--data '{
"channel": "C079A5A8BL0",
"text": "PR 알림",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*작성자:* '${{ github.actor }}'
*PR 링크:* '${{ github.event.pull_request.html_url }}'"
}
}
]
}' https://slack.com/api/chat.postMessage)
echo "$response" > output.json
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Extract mentions from comment body
id: extract_mentions_comment
Expand All @@ -51,22 +57,19 @@ jobs:
echo "::set-output name=slack_mentions::$slack_mentions"

- name: Send Slack Notification for comment if team members mentioned
if: ${{ github.event_name == 'issue_comment' && steps.map_to_slack_ids.outputs.slack_mentions != '' }}
uses: 8398a7/action-slack@v3
with:
status: custom
fields: pullRequest
custom_payload: |
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `${process.env.AS_PULL_REQUEST}에서 ${{ steps.map_to_slack_ids.outputs.slack_mentions }} 님을 언급했습니다.
꼭 나중에 들어가서 확인하기!
메시지: ${{ github.event.comment.body }}`,
}]
}
if: github.event_name == 'issue_comment' && steps.map_to_slack_ids.outputs.slack_mentions != ''
run: |
ts=$(jq -r '.ts' output.json)
curl -X POST -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" -H "Content-type: application/json" \
--data '{
"channel": "C079A5A8BL0",
"thread_ts": "'"$ts"'",
"text": "'${{ steps.map_to_slack_ids.outputs.slack_mentions }}' 님을 언급했습니다.
꼭 나중에 확인해주세요!
메시지: '${{ github.event.comment.body }}'"
}' https://slack.com/api/chat.postMessage
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}

- name: Debug mentions
if: ${{ github.event_name == 'issue_comment' && steps.map_to_slack_ids.outputs.slack_mentions == '' }}
Expand Down