[HOTFIX] 잔여 Q&A 이슈 해결 #2690
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Slack Notification from GitHub Comments | |
| on: | |
| issue_comment: | |
| types: [created] | |
| pull_request_review: | |
| types: [submitted] | |
| pull_request_review_comment: | |
| types: [created] | |
| jobs: | |
| notify-slack: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set Comment Content | |
| id: set-comment | |
| run: | | |
| COMMENT="${{ github.event.comment.body }}" | |
| if [[ -z "$COMMENT" ]]; then | |
| COMMENT="${{ github.event.review.body }}" | |
| fi | |
| echo "COMMENT<<EOF" >> $GITHUB_ENV | |
| echo "$COMMENT" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Check Notification Command | |
| id: check-command | |
| run: | | |
| COMMENT="${{ env.COMMENT }}" | |
| # 공백 제거 후 체크 | |
| TRIMMED_COMMENT=$(echo "$COMMENT" | sed 's/^[[:space:]]*//') | |
| if [[ "$TRIMMED_COMMENT" =~ ^/noti-be ]]; then | |
| echo "WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL_BE }}" >> $GITHUB_ENV | |
| echo "NOTI_TYPE=be" >> $GITHUB_ENV | |
| elif [[ "$TRIMMED_COMMENT" =~ ^/noti-fe ]]; then | |
| echo "WEBHOOK_URL=${{ secrets.SLACK_WEBHOOK_URL_FE }}" >> $GITHUB_ENV | |
| echo "NOTI_TYPE=fe" >> $GITHUB_ENV | |
| else | |
| echo "Not a notification command (must start with /noti-be or /noti-fe)" | |
| exit 0 | |
| fi | |
| - name: Map GitHub Users to Slack IDs | |
| if: env.WEBHOOK_URL | |
| run: | | |
| COMMENT="${{ env.COMMENT }}" | |
| # GitHub 멘션을 Slack 멘션으로 변환 | |
| MAPPED_COMMENT="$COMMENT" | |
| MAPPED_COMMENT="${MAPPED_COMMENT//@joyjhm/<@${{ secrets.HYUNMIN_SLACK_ID }}>}" | |
| MAPPED_COMMENT="${MAPPED_COMMENT//@coli-geonwoo/<@${{ secrets.GEONWOO_SLACK_ID }}>}" | |
| MAPPED_COMMENT="${MAPPED_COMMENT//@yeonjinJoo/<@${{ secrets.YEONJIN_SLACK_ID }}>}" | |
| MAPPED_COMMENT="${MAPPED_COMMENT//@bonsng/<@${{ secrets.BONSNG_SLACK_ID }}>}" | |
| MAPPED_COMMENT="${MAPPED_COMMENT//@rkdwoals159/<@${{ secrets.JAEMIN_SLACK_ID }}>}" | |
| MAPPED_COMMENT="${MAPPED_COMMENT//@yyoonngg/<@${{ secrets.YOUNGHYUN_SLACK_ID }}>}" | |
| echo "MAPPED_COMMENT<<EOF" >> $GITHUB_ENV | |
| echo "$MAPPED_COMMENT" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| - name: Set PR URL | |
| if: env.WEBHOOK_URL | |
| run: | | |
| if [[ "${{ github.event.issue.html_url }}" != "" ]]; then | |
| echo "PR_URL=${{ github.event.issue.html_url }}" >> $GITHUB_ENV | |
| elif [[ "${{ github.event.pull_request.html_url }}" != "" ]]; then | |
| echo "PR_URL=${{ github.event.pull_request.html_url }}" >> $GITHUB_ENV | |
| else | |
| echo "PR_URL=${{ github.event.review.html_url }}" >> $GITHUB_ENV | |
| fi | |
| - name: Send Notification to Slack | |
| if: env.WEBHOOK_URL | |
| run: | | |
| CLEAN_COMMENT="${{ env.MAPPED_COMMENT }}" | |
| PR_URL="${{ env.PR_URL }}" | |
| jq -n \ | |
| --arg text "$CLEAN_COMMENT\n\n<$PR_URL|View PR>" \ | |
| '{text: $text}' \ | |
| | curl -X POST "${{ env.WEBHOOK_URL }}" \ | |
| -H 'Content-Type: application/json' \ | |
| -d @- |