Skip to content

Commit

Permalink
fix: 슬랙 멘션 기능 테스트
Browse files Browse the repository at this point in the history
  • Loading branch information
lilychoibb committed Jul 18, 2024
1 parent f04491c commit 77a2e18
Showing 1 changed file with 5 additions and 19 deletions.
24 changes: 5 additions & 19 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,33 +37,19 @@ jobs:
cd backend
./gradlew build
- name: Set up Slack user mapping
id: slack-user-mapping
run: |
EMAIL=$(git log -1 --pretty=format:'%ae')
case "$EMAIL" in
"[email protected]") SLACK_USER_ID="U07AQJWU8S3" ;; # @릴리
*) SLACK_USER_ID="" ;;
esac
echo "::set-output name=slack_user_id::$SLACK_USER_ID"
- name: Prepare Slack mention
id: prepare-slack-mention
- name: Send Slack notification on failure
if: failure()
run: |
if [ "${{ steps.slack-user-mapping.outputs.slack_user_id }}" != "" ]; then
echo "::set-output name=slack_mention::<@${{ steps.slack-user-mapping.outputs.slack_user_id }}>"
else
echo "::set-output name=slack_mention::"
fi
SLACK_WEBHOOK_URL=https://hooks.slack.com/services/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
TEXT="<@U012AB3CD>, there was a failure in the CI pipeline for commit $GITHUB_SHA"
curl -X POST -H 'Content-type: application/json' --data '{"text": "'"$TEXT"'"}' $SLACK_WEBHOOK_URL
- name: Send Slack notification
uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
author_name: Github Action Test
fields: repo,pullRequest,eventName,author,message,commit,action,took
mention: '${{ steps.prepare-slack-mention.outputs.slack_mention }}'
if_mention: failure,cancelled
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: failure()

0 comments on commit 77a2e18

Please sign in to comment.