Skip to content

Commit

Permalink
chore: PR 코멘트 스레드 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeJeongHooo committed Jun 24, 2024
1 parent 80f530b commit 069130d
Showing 1 changed file with 31 additions and 27 deletions.
58 changes: 31 additions & 27 deletions .github/workflows/slack-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,27 @@ 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": "#general",
"text": "PR 알림",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Actor:* '${{ github.actor }}'
*PR:* '${{ github.event.pull_request.html_url }}'"
}
}
]
}' https://slack.com/api/chat.postMessage)
ts=$(echo $response | jq -r '.ts')
echo "::set-output name=ts::$ts"
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 @@ -52,21 +59,18 @@ jobs:
- 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 }}`,
}]
}
run: |
ts="${{ steps.send_pr_notification.outputs.ts }}"
curl -X POST -H "Authorization: Bearer ${{ secrets.SLACK_BOT_TOKEN }}" -H "Content-type: application/json" \
--data '{
"channel": "#general",
"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

0 comments on commit 069130d

Please sign in to comment.