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

fix(*): slack notification 메시지 수정 #20

Merged
merged 2 commits into from
Jun 24, 2024
Merged
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
30 changes: 24 additions & 6 deletions .github/workflows/slack-notification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,16 @@ jobs:
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: commit,author,pullRequest
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}`,
}]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}

Expand All @@ -27,15 +35,24 @@ jobs:
mentions=$(echo "${{ github.event.comment.body }}" | grep -o '@[[:alnum:]_-]\+' | paste -sd ' ' -)
echo "::set-output name=mentions::$mentions"

- name: Transform mentions to Slack format
id: transform_mentions
if: github.event_name == 'issue_comment'
run: |
mentions="${{ steps.extract_mentions_comment.outputs.mentions }}"
# Transform specific mentions to desired format
transformed_mentions=$(echo "$mentions" | sed -E 's/@Doeunnkimm/@Web_김도은/g; s/@semnil5202/@Web_이세민/g; s/@Andrevile/@Web_장종오/g; s/@LeeJeongHooo/@Web_이정호/g')
echo "::set-output name=transformed_mentions::$transformed_mentions"

- name: Filter mentions for team members
id: filter_mentions
if: github.event_name == 'issue_comment'
run: |
mentions="${{ steps.extract_mentions_comment.outputs.mentions }}"
team_members=(Doeunnkimm semnil5202 Andrevile LeeJeongHooo)
mentions="${{ steps.transform_mentions.outputs.transformed_mentions }}"
team_members=(@Web_김도은 @Web_이세민 @Web_장종오 @Web_이정호)
filtered_mentions=""
for mention in $mentions; do
if [[ " ${team_members[@]} " =~ " ${mention#@} " ]]; then
if [[ " ${team_members[@]} " =~ " ${mention} " ]]; then
filtered_mentions="$filtered_mentions $mention"
fi
done
Expand All @@ -51,7 +68,8 @@ jobs:
{
attachments: [{
color: '${{ job.status }}' === 'success' ? 'good' : '${{ job.status }}' === 'failure' ? 'danger' : 'warning',
text: `${process.env.AS_PULLREQUEST} - MSG: ${{ github.event.comment.body }}`,
text: `${process.env.AS_PULL_REQUEST}에서 ${{ steps.filter_mentions.outputs.filtered_mentions }} 님을 언급했습니다.
꼭 나중에 들어가서 확인하기!\\n메시지: ${{ github.event.comment.body }}`,
}]
}
env:
Expand Down
Loading