[Feat] TimeTagSpinner Compose ๋ง์ด๊ทธ๋ ์ด์ #7
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 (Review Requested) | |
| on: | |
| pull_request: | |
| types: [review_requested] | |
| permissions: | |
| contents: read | |
| pull-requests: read | |
| concurrency: | |
| group: pr-${{ github.event.pull_request.number }}-slack-review-requested | |
| cancel-in-progress: true | |
| # ์ฌ๋ฆฌ๋ทฐ ์์ฒญ ์๋ฆผ | |
| jobs: | |
| notify: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # JSON ํ์ฑ ๋๊ตฌ | |
| - name: Install jq | |
| run: sudo apt-get update && sudo apt-get install -y jq | |
| - name: Notify Re-review Requested | |
| env: | |
| SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| GITHUB_TOKEN: ${{ github.token }} | |
| PR_TITLE: ${{ github.event.pull_request.title }} | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| PR_URL: ${{ github.event.pull_request.html_url }} | |
| PR_AUTHOR: ${{ github.event.pull_request.user.login }} | |
| PR_REVIEWER: ${{ github.event.requested_reviewer.login }} | |
| REPOSITORY: ${{ github.repository }} | |
| run: | | |
| declare -A GITHUB_TO_SLACK | |
| GITHUB_TO_SLACK["soeun2537"]="U09A0LM0CRW" | |
| GITHUB_TO_SLACK["taek2222"]="U099ARRH3D3" | |
| GITHUB_TO_SLACK["changuii"]="U099BR9RNE6" | |
| GITHUB_TO_SLACK["eoehd1ek"]="U0995NANDML" | |
| GITHUB_TO_SLACK["oungsi2000"]="U098U2R57NK" | |
| GITHUB_TO_SLACK["parkjiminnnn"]="U098U8SLXHD" | |
| GITHUB_TO_SLACK["etama123"]="U0995MPSZ62" | |
| if [[ "$PR_REVIEWER" == *"[bot]" ]]; then | |
| echo "Bot ๊ณ์ ๋ฆฌ๋ทฐ ์์ฒญ์ ์๋ฆผ ์๋ต" | |
| exit 0 | |
| fi | |
| REVIEW_API_URL="https://api.github.com/repos/$REPOSITORY/pulls/$PR_NUMBER/reviews" | |
| REVIEW_COUNT=$(curl -s -H "Authorization: Bearer $GITHUB_TOKEN" "$REVIEW_API_URL" \ | |
| | jq -r --arg reviewer "$PR_REVIEWER" '[.[] | select(.user.login == $reviewer)] | length') | |
| if [ "$REVIEW_COUNT" -eq 0 ]; then | |
| echo "์ต์ด ๋ฆฌ๋ทฐ ์์ฒญ์ผ๋ก ๊ฐ์ฃผ๋์ด ์๋ฆผ ์๋ต" | |
| exit 0 | |
| fi | |
| slack_id=${GITHUB_TO_SLACK[$PR_REVIEWER]} | |
| if [[ -z "$slack_id" ]]; then | |
| echo "๋งคํ ์๋ ์ฌ์ฉ์(${PR_REVIEWER})๋ ์๋ต" | |
| exit 0 | |
| fi | |
| if [[ -n "${GITHUB_TO_SLACK[$PR_AUTHOR]}" ]]; then | |
| SLACK_AUTHOR_MENTION="<@${GITHUB_TO_SLACK[$PR_AUTHOR]}>" | |
| else | |
| SLACK_AUTHOR_MENTION="@${PR_AUTHOR}" # ํ๋ฌธ | |
| fi | |
| SLACK_REVIEWER_MENTION="<@$slack_id>" | |
| curl -X POST -H 'Content-type: application/json' \ | |
| --data "{\"text\": \"๐ธ *์ฌ๋ฆฌ๋ทฐ ์์ฒญ ์๋ฆผ*\n*PR ์ ๋ชฉ:* ${PR_TITLE} (#${PR_NUMBER})\n*์์ฑ์:* ${SLACK_AUTHOR_MENTION}\n*๋ฆฌ๋ทฐ์ด:* ${SLACK_REVIEWER_MENTION}\n*๋งํฌ:* ${PR_URL}\"}" \ | |
| $SLACK_WEBHOOK_URL |