Skip to content

슬랙핑 테스트3 #9

슬랙핑 테스트3

슬랙핑 테스트3 #9

Workflow file for this run

name: Slack Ping
on:
pull_request:
types:
- review_requested
pull_request_review:
types:
- submitted
issue_comment:
types:
- created
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Send Slack message
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_USER_ID: ${{ secrets.SLACK_USER_ID }}
run: |
MESSAGE=""
SLACK_USER_ID=""
if [[ "${{ github.event.requested_reviewer.login }}" == "LURKS02" ]]; then
SLACK_USER_ID=$SLACK_USER_ID
fi
if [[ "${{ github.event_name }}" == "pull_request" ]]; then
MESSAGE="PR이 등록되었습니다. 제목: ${{ github.event.pull_request.title }} - 링크: ${{ github.event.pull_request.html_url }}"
# if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.event.action }}" == "review_requested" ]]; then
# MESSAGE="리뷰 요청: 나를 리뷰어로 지정한 PR이 생성되었습니다. 제목: ${{ github.event.pull_request.title }} - 링크: ${{ github.event.pull_request.html_url }}"
# for GITHUB_USER in $(echo "${{ toJson(github.event.pull_request.requested_reviewers) }}" | jq -r '.[].login'); do
# SLACK_USER_ID=
elif [[ "${{ github.event_name }}" == "pull_request_review" ]] && [[ "${{ github.event.action }}" == "submitted" ]]; then
MESSAGE="리뷰 완료(${{ github.event.review.state }}): 내 PR에 리뷰어가 리뷰를 완료했습니다. 제목: ${{ github.event.pull_request.title }} - 링크: ${{ github.event.pull_request.html_url }}"
fi
if [[ -n "$MESSAGE" ]]; then
curl -X POST -H "Authorization: Bearer $SLACK_TOKEN" -H "Content-Type: application/json" \
-d "{\"channel\":\"$SLACK_USER_ID\", \"text\":\"$MESSAGE\"}" \
https://slack.com/api/chat.postMessage
fi