From be9cca339a30cf845125be162358f76cdffdf280 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:27:53 +0900 Subject: [PATCH 01/23] tmp --- apps/web/app/second/page.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/web/app/second/page.tsx b/apps/web/app/second/page.tsx index 357ea283..000451d6 100644 --- a/apps/web/app/second/page.tsx +++ b/apps/web/app/second/page.tsx @@ -1,5 +1,4 @@ import { SecondDomainExampleScreen } from '@sambad/domains/second-domain'; -import Image from 'next/image'; import styles from '../page.module.css'; @@ -7,6 +6,7 @@ export default function Second() { return (
+ test
); } From e308ab02fd3e2e93073d777b271a0c275357242e Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:30:54 +0900 Subject: [PATCH 02/23] fix --- .github/workflows/slack-notification.yml | 94 ++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 .github/workflows/slack-notification.yml diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml new file mode 100644 index 00000000..c1181958 --- /dev/null +++ b/.github/workflows/slack-notification.yml @@ -0,0 +1,94 @@ +name: Slack Notification + +on: + pull_request: + types: [opened, ready_for_review] + issue_comment: + types: [created, edited] + +jobs: + send_slack_notification: + name: Send Slack Notification + runs-on: ubuntu-latest + steps: + - name: Determine color for PR creation + id: determine_color_pr + if: github.event_name == 'pull_request' && github.event.pull_request.draft == false + run: | + if [ "${{ job.status }}" == "success" ]; then + echo "color=good" >> $GITHUB_ENV + elif [ "${{ job.status }}" == "failure" ]; then + echo "color=danger" >> $GITHUB_ENV + else + echo "color=warning" >> $GITHUB_ENV + fi + + - name: Send Slack Notification for PR creation + if: github.event_name == 'pull_request' && github.event.pull_request.draft == false + uses: 8398a7/action-slack@v3 + with: + status: custom + fields: author,pullRequest + custom_payload: | + { + "attachments": [{ + "color": "${{ env.color }}", + "text": "Actor: ${{ github.actor }}\nPR: ${{ github.event.pull_request.html_url }}" + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Extract mentions from comment body + id: extract_mentions_comment + if: github.event_name == 'issue_comment' + run: | + mentions=$(echo "${{ github.event.comment.body }}" | grep -o '@[[:alnum:]_-]\+' | paste -sd ' ' -) + echo "mentions=$mentions" >> $GITHUB_ENV + + - name: Map GitHub mentions to Slack user IDs + id: map_to_slack_ids + if: github.event_name == 'issue_comment' + run: | + declare -A slack_ids + slack_ids=(["@Doeunnkimm"]="U07600UQG3T" ["@semnil5202"]="U075KR29RGR" ["@Andrevile"]="U07545VMS21" ["@LeeJeongHooo"]="U075C1A16LT") + mentions="${{ env.mentions }}" + slack_mentions="" + for mention in $mentions; do + if [[ -n "${slack_ids[$mention]}" ]]; then + slack_mentions="$slack_mentions <@${slack_ids[$mention]}>" + fi + done + echo "slack_mentions=$slack_mentions" >> $GITHUB_ENV + + - name: Determine color for comment mention + id: determine_color_comment + if: github.event_name == 'issue_comment' && env.slack_mentions != '' + run: | + if [ "${{ job.status }}" == "success" ]; then + echo "color=good" >> $GITHUB_ENV + elif [ "${{ job.status }}" == "failure" ]; then + echo "color=danger" >> $GITHUB_ENV + else + echo "color=warning" >> $GITHUB_ENV + fi + + - name: Send Slack Notification for comment if team members mentioned + if: github.event_name == 'issue_comment' && env.slack_mentions != '' + uses: 8398a7/action-slack@v3 + with: + status: custom + fields: pullRequest + custom_payload: | + { + "attachments": [{ + "color": "${{ env.color }}", + "text": "${{ github.event.pull_request.html_url }} 에서 ${{ env.slack_mentions }} 님을 언급했습니다.\n꼭 나중에 들어가서 확인하기!\n메시지: ${{ github.event.comment.body }}" + }] + } + env: + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + + - name: Debug mentions + if: github.event_name == 'issue_comment' && env.slack_mentions == '' + run: echo "No team members mentioned in the comment." From a0e332b78f39279d586c3b6bd0f21aad71c35096 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:33:26 +0900 Subject: [PATCH 03/23] fix --- .github/workflows/slack-notification.yml | 53 ++++++++++++++---------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index c1181958..d25b3f69 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -11,6 +11,37 @@ jobs: name: Send Slack Notification runs-on: ubuntu-latest steps: + - name: Check out the repository + uses: actions/checkout@v2 + + - name: Read user mapping from JSON + id: read_user_mapping + run: | + mapping=$(cat .github/user-mapping.json) + echo "mapping=$mapping" >> $GITHUB_ENV + + - name: Extract mentions from comment body + id: extract_mentions_comment + if: github.event_name == 'issue_comment' + run: | + mentions=$(echo "${{ github.event.comment.body }}" | grep -o '@[[:alnum:]_-]\+' | paste -sd ' ' -) + echo "mentions=$mentions" >> $GITHUB_ENV + + - name: Map GitHub mentions to Slack user IDs + id: map_to_slack_ids + if: github.event_name == 'issue_comment' + run: | + mentions="${{ env.mentions }}" + slack_mentions="" + while IFS= read -r mention; do + user=$(echo $mention | sed 's/@//') + slack_user=$(echo ${{ env.mapping }} | jq -r --arg user "$user" '.[$user]') + if [[ -n "$slack_user" ]]; then + slack_mentions="$slack_mentions $slack_user" + fi + done <<< "$mentions" + echo "slack_mentions=$slack_mentions" >> $GITHUB_ENV + - name: Determine color for PR creation id: determine_color_pr if: github.event_name == 'pull_request' && github.event.pull_request.draft == false @@ -39,28 +70,6 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} - - name: Extract mentions from comment body - id: extract_mentions_comment - if: github.event_name == 'issue_comment' - run: | - mentions=$(echo "${{ github.event.comment.body }}" | grep -o '@[[:alnum:]_-]\+' | paste -sd ' ' -) - echo "mentions=$mentions" >> $GITHUB_ENV - - - name: Map GitHub mentions to Slack user IDs - id: map_to_slack_ids - if: github.event_name == 'issue_comment' - run: | - declare -A slack_ids - slack_ids=(["@Doeunnkimm"]="U07600UQG3T" ["@semnil5202"]="U075KR29RGR" ["@Andrevile"]="U07545VMS21" ["@LeeJeongHooo"]="U075C1A16LT") - mentions="${{ env.mentions }}" - slack_mentions="" - for mention in $mentions; do - if [[ -n "${slack_ids[$mention]}" ]]; then - slack_mentions="$slack_mentions <@${slack_ids[$mention]}>" - fi - done - echo "slack_mentions=$slack_mentions" >> $GITHUB_ENV - - name: Determine color for comment mention id: determine_color_comment if: github.event_name == 'issue_comment' && env.slack_mentions != '' From e21d480f877905f3874975f6786f5d8723c3c9ad Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:36:04 +0900 Subject: [PATCH 04/23] fix --- .github/workflows/slack-notification.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index d25b3f69..8f91f846 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -14,6 +14,12 @@ jobs: - name: Check out the repository uses: actions/checkout@v2 + - name: Debug - List files in .github directory + run: ls -la .github + + - name: Debug - Cat user-mapping.json + run: cat .github/user-mapping.json + - name: Read user mapping from JSON id: read_user_mapping run: | From 7bb3cfdbc31d15b17c4387ea1cb28751b2f7dcdf Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:37:41 +0900 Subject: [PATCH 05/23] fix --- .github/workflows/slack-notification.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index 8f91f846..9606ab27 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -23,8 +23,9 @@ jobs: - name: Read user mapping from JSON id: read_user_mapping run: | - mapping=$(cat .github/user-mapping.json) - echo "mapping=$mapping" >> $GITHUB_ENV + echo "Reading user mapping" + mapping=$(cat .github/user-mapping.json | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]') + echo "$mapping" >> $GITHUB_ENV - name: Extract mentions from comment body id: extract_mentions_comment @@ -39,13 +40,13 @@ jobs: run: | mentions="${{ env.mentions }}" slack_mentions="" - while IFS= read -r mention; do + for mention in $mentions; do user=$(echo $mention | sed 's/@//') - slack_user=$(echo ${{ env.mapping }} | jq -r --arg user "$user" '.[$user]') + slack_user=$(eval echo \${$user}) if [[ -n "$slack_user" ]]; then slack_mentions="$slack_mentions $slack_user" fi - done <<< "$mentions" + done echo "slack_mentions=$slack_mentions" >> $GITHUB_ENV - name: Determine color for PR creation From 29cd018c756f83b57fb8ff4f1eb96d373807e19d Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:39:56 +0900 Subject: [PATCH 06/23] fix --- .github/workflows/slack-notification.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index 9606ab27..364ce2a7 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -24,8 +24,9 @@ jobs: id: read_user_mapping run: | echo "Reading user mapping" - mapping=$(cat .github/user-mapping.json | jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]') - echo "$mapping" >> $GITHUB_ENV + while IFS="=" read -r key value; do + echo "${key}=${value}" >> $GITHUB_ENV + done < <(jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' .github/user-mapping.json) - name: Extract mentions from comment body id: extract_mentions_comment @@ -87,7 +88,6 @@ jobs: echo "color=danger" >> $GITHUB_ENV else echo "color=warning" >> $GITHUB_ENV - fi - name: Send Slack Notification for comment if team members mentioned if: github.event_name == 'issue_comment' && env.slack_mentions != '' From c2e8ec29be85a9acdc462f671bd1b63ca228a38e Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:46:22 +0900 Subject: [PATCH 07/23] fix --- .github/workflows/slack-notification.yml | 167 +++++++++++------------ 1 file changed, 83 insertions(+), 84 deletions(-) diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml index 364ce2a7..562563cb 100644 --- a/.github/workflows/slack-notification.yml +++ b/.github/workflows/slack-notification.yml @@ -1,110 +1,109 @@ -name: Slack Notification +name: Notify Slack on PR and Comment on: pull_request: - types: [opened, ready_for_review] + types: [opened, reopened, synchronize, review_requested] issue_comment: - types: [created, edited] + types: [created] + pull_request_review: + types: [submitted] jobs: - send_slack_notification: - name: Send Slack Notification + notify: runs-on: ubuntu-latest + steps: - - name: Check out the repository + - name: Checkout repository uses: actions/checkout@v2 - - name: Debug - List files in .github directory - run: ls -la .github - - - name: Debug - Cat user-mapping.json - run: cat .github/user-mapping.json + - name: Determine event type + id: determine_event + run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - - name: Read user mapping from JSON - id: read_user_mapping + - name: Read user mapping + id: read_mapping run: | - echo "Reading user mapping" - while IFS="=" read -r key value; do - echo "${key}=${value}" >> $GITHUB_ENV - done < <(jq -r 'to_entries|map("\(.key)=\(.value|tostring)")|.[]' .github/user-mapping.json) + mapping=$(cat .github/user-mapping.json) + echo "mapping=$mapping" >> $GITHUB_ENV - - name: Extract mentions from comment body - id: extract_mentions_comment - if: github.event_name == 'issue_comment' - run: | - mentions=$(echo "${{ github.event.comment.body }}" | grep -o '@[[:alnum:]_-]\+' | paste -sd ' ' -) - echo "mentions=$mentions" >> $GITHUB_ENV + - name: Cache Slack message timestamp + if: ${{ env.event_type == 'pull_request' }} + uses: actions/cache@v2 + with: + path: slack_ts.txt + key: slack-ts-${{ github.event.pull_request.number }} - - name: Map GitHub mentions to Slack user IDs - id: map_to_slack_ids - if: github.event_name == 'issue_comment' + - name: Send notification for PR + if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + id: slack_pr run: | - mentions="${{ env.mentions }}" - slack_mentions="" - for mention in $mentions; do - user=$(echo $mention | sed 's/@//') - slack_user=$(eval echo \${$user}) - if [[ -n "$slack_user" ]]; then - slack_mentions="$slack_mentions $slack_user" - fi - done - echo "slack_mentions=$slack_mentions" >> $GITHUB_ENV + response=$(curl -X POST -H 'Content-type: application/json' --data '{ + "text": "🧞‍♂️ PR 드리는 지니가 왔습니다\n[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})\n${{ github.event.pull_request.user.login }}님이 생성했어요." + }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) + echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV + echo $slack_ts > slack_ts.txt + env: + SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - name: Determine color for PR creation - id: determine_color_pr - if: github.event_name == 'pull_request' && github.event.pull_request.draft == false + - name: Send notification for review request + if: ${{ env.event_type == 'pull_request' && github.event.action == 'review_requested' }} run: | - if [ "${{ job.status }}" == "success" ]; then - echo "color=good" >> $GITHUB_ENV - elif [ "${{ job.status }}" == "failure" ]; then - echo "color=danger" >> $GITHUB_ENV + reviewer=${{ github.event.requested_reviewer.login }} + slack_username=$(echo ${{ env.mapping }} | jq -r --arg reviewer "$reviewer" '.[$reviewer]') + if [ "$slack_username" != "null" ]; then + response=$(curl -X POST -H 'Content-type: application/json' --data '{ + "text": "🔔 리뷰 요청이 도착했습니다: @'$slack_username'" + }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) + echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV + echo $slack_ts > slack_ts.txt else - echo "color=warning" >> $GITHUB_ENV + echo "Reviewer not found in mapping: $reviewer" fi + env: + SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - name: Send Slack Notification for PR creation - if: github.event_name == 'pull_request' && github.event.pull_request.draft == false - uses: 8398a7/action-slack@v3 + - name: Restore Slack message timestamp + if: ${{ env.event_type == 'issue_comment' || env.event_type == 'pull_request_review' }} + id: restore_ts + uses: actions/cache@v2 with: - status: custom - fields: author,pullRequest - custom_payload: | - { - "attachments": [{ - "color": "${{ env.color }}", - "text": "Actor: ${{ github.actor }}\nPR: ${{ github.event.pull_request.html_url }}" - }] - } - env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + path: slack_ts.txt + key: slack-ts-${{ github.event.issue.number || github.event.pull_request.number }} + restore-keys: | + slack-ts- + + - name: Load Slack message timestamp + if: ${{ (env.event_type == 'issue_comment' || env.event_type == 'pull_request_review') && steps.restore_ts.outputs.cache-hit == 'true' }} + run: echo "SLACK_MESSAGE_TS=$(cat slack_ts.txt)" >> $GITHUB_ENV - - name: Determine color for comment mention - id: determine_color_comment - if: github.event_name == 'issue_comment' && env.slack_mentions != '' + - name: Send notification for comment + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | - if [ "${{ job.status }}" == "success" ]; then - echo "color=good" >> $GITHUB_ENV - elif [ "${{ job.status }}" == "failure" ]; then - echo "color=danger" >> $GITHUB_ENV + commenter=${{ github.event.comment.user.login }} + slack_username=$(echo ${{ env.mapping }} | jq -r --arg commenter "$commenter" '.[$commenter]') + if [ "$slack_username" != "null" ]; then + curl -X POST -H 'Content-type: application/json' --data '{ + "text": "@'$slack_username'님이 코멘트를 달았습니다:\n${{ github.event.comment.body }}", + "thread_ts": "${{ env.SLACK_MESSAGE_TS }}" + }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} else - echo "color=warning" >> $GITHUB_ENV - - - name: Send Slack Notification for comment if team members mentioned - if: github.event_name == 'issue_comment' && env.slack_mentions != '' - uses: 8398a7/action-slack@v3 - with: - status: custom - fields: pullRequest - custom_payload: | - { - "attachments": [{ - "color": "${{ env.color }}", - "text": "${{ github.event.pull_request.html_url }} 에서 ${{ env.slack_mentions }} 님을 언급했습니다.\n꼭 나중에 들어가서 확인하기!\n메시지: ${{ github.event.comment.body }}" - }] - } + echo "Commenter not found in mapping: $commenter" + fi env: - SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} + SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - name: Debug mentions - if: github.event_name == 'issue_comment' && env.slack_mentions == '' - run: echo "No team members mentioned in the comment." + - name: Send notification for approval + if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} + run: | + reviewer=${{ github.event.review.user.login }} + slack_username=$(echo ${{ env.mapping }} | jq -r --arg reviewer "$reviewer" '.[$reviewer]') + if [ "$slack_username" != "null" ]; then + curl -X POST -H 'Content-type: application/json' --data '{ + "text": "✅ @'$slack_username'님이 승인하셨어요 🎉", + "thread_ts": "${{ env.SLACK_MESSAGE_TS }}" + }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} + else + echo "Reviewer not found in mapping: $reviewer" + fi + env: + SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} From b24e37d08cc5cfe9a223ab4ad73f4892447bcc0e Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:48:45 +0900 Subject: [PATCH 08/23] fix --- .github/workflows/slack-notification.yml | 109 ----------------------- .github/workflows/slack-notify.yml | 12 +-- 2 files changed, 3 insertions(+), 118 deletions(-) delete mode 100644 .github/workflows/slack-notification.yml diff --git a/.github/workflows/slack-notification.yml b/.github/workflows/slack-notification.yml deleted file mode 100644 index 562563cb..00000000 --- a/.github/workflows/slack-notification.yml +++ /dev/null @@ -1,109 +0,0 @@ -name: Notify Slack on PR and Comment - -on: - pull_request: - types: [opened, reopened, synchronize, review_requested] - issue_comment: - types: [created] - pull_request_review: - types: [submitted] - -jobs: - notify: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v2 - - - name: Determine event type - id: determine_event - run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - - - name: Read user mapping - id: read_mapping - run: | - mapping=$(cat .github/user-mapping.json) - echo "mapping=$mapping" >> $GITHUB_ENV - - - name: Cache Slack message timestamp - if: ${{ env.event_type == 'pull_request' }} - uses: actions/cache@v2 - with: - path: slack_ts.txt - key: slack-ts-${{ github.event.pull_request.number }} - - - name: Send notification for PR - if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} - id: slack_pr - run: | - response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "🧞‍♂️ PR 드리는 지니가 왔습니다\n[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})\n${{ github.event.pull_request.user.login }}님이 생성했어요." - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) - echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV - echo $slack_ts > slack_ts.txt - env: - SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - - name: Send notification for review request - if: ${{ env.event_type == 'pull_request' && github.event.action == 'review_requested' }} - run: | - reviewer=${{ github.event.requested_reviewer.login }} - slack_username=$(echo ${{ env.mapping }} | jq -r --arg reviewer "$reviewer" '.[$reviewer]') - if [ "$slack_username" != "null" ]; then - response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "🔔 리뷰 요청이 도착했습니다: @'$slack_username'" - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) - echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV - echo $slack_ts > slack_ts.txt - else - echo "Reviewer not found in mapping: $reviewer" - fi - env: - SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - - name: Restore Slack message timestamp - if: ${{ env.event_type == 'issue_comment' || env.event_type == 'pull_request_review' }} - id: restore_ts - uses: actions/cache@v2 - with: - path: slack_ts.txt - key: slack-ts-${{ github.event.issue.number || github.event.pull_request.number }} - restore-keys: | - slack-ts- - - - name: Load Slack message timestamp - if: ${{ (env.event_type == 'issue_comment' || env.event_type == 'pull_request_review') && steps.restore_ts.outputs.cache-hit == 'true' }} - run: echo "SLACK_MESSAGE_TS=$(cat slack_ts.txt)" >> $GITHUB_ENV - - - name: Send notification for comment - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} - run: | - commenter=${{ github.event.comment.user.login }} - slack_username=$(echo ${{ env.mapping }} | jq -r --arg commenter "$commenter" '.[$commenter]') - if [ "$slack_username" != "null" ]; then - curl -X POST -H 'Content-type: application/json' --data '{ - "text": "@'$slack_username'님이 코멘트를 달았습니다:\n${{ github.event.comment.body }}", - "thread_ts": "${{ env.SLACK_MESSAGE_TS }}" - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - else - echo "Commenter not found in mapping: $commenter" - fi - env: - SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - - name: Send notification for approval - if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} - run: | - reviewer=${{ github.event.review.user.login }} - slack_username=$(echo ${{ env.mapping }} | jq -r --arg reviewer "$reviewer" '.[$reviewer]') - if [ "$slack_username" != "null" ]; then - curl -X POST -H 'Content-type: application/json' --data '{ - "text": "✅ @'$slack_username'님이 승인하셨어요 🎉", - "thread_ts": "${{ env.SLACK_MESSAGE_TS }}" - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - else - echo "Reviewer not found in mapping: $reviewer" - fi - env: - SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 562563cb..2ab624ec 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -20,12 +20,6 @@ jobs: id: determine_event run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - - name: Read user mapping - id: read_mapping - run: | - mapping=$(cat .github/user-mapping.json) - echo "mapping=$mapping" >> $GITHUB_ENV - - name: Cache Slack message timestamp if: ${{ env.event_type == 'pull_request' }} uses: actions/cache@v2 @@ -49,7 +43,7 @@ jobs: if: ${{ env.event_type == 'pull_request' && github.event.action == 'review_requested' }} run: | reviewer=${{ github.event.requested_reviewer.login }} - slack_username=$(echo ${{ env.mapping }} | jq -r --arg reviewer "$reviewer" '.[$reviewer]') + slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') if [ "$slack_username" != "null" ]; then response=$(curl -X POST -H 'Content-type: application/json' --data '{ "text": "🔔 리뷰 요청이 도착했습니다: @'$slack_username'" @@ -80,7 +74,7 @@ jobs: if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} - slack_username=$(echo ${{ env.mapping }} | jq -r --arg commenter "$commenter" '.[$commenter]') + slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ "text": "@'$slack_username'님이 코멘트를 달았습니다:\n${{ github.event.comment.body }}", @@ -96,7 +90,7 @@ jobs: if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} run: | reviewer=${{ github.event.review.user.login }} - slack_username=$(echo ${{ env.mapping }} | jq -r --arg reviewer "$reviewer" '.[$reviewer]') + slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ "text": "✅ @'$slack_username'님이 승인하셨어요 🎉", From 6c674db364729923292a7169d69beff019c48031 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:56:17 +0900 Subject: [PATCH 09/23] fix --- .github/workflows/slack-notify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 2ab624ec..bdac2d15 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -77,7 +77,7 @@ jobs: slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ - "text": "@'$slack_username'님이 코멘트를 달았습니다:\n${{ github.event.comment.body }}", + "text": "@'$slack_username'님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", "thread_ts": "${{ env.SLACK_MESSAGE_TS }}" }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} else From fb5eafe293e01411b341d3350630640ae5f1e609 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 22:59:43 +0900 Subject: [PATCH 10/23] fix --- .github/workflows/slack-notify.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index bdac2d15..1b58c404 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -32,7 +32,7 @@ jobs: id: slack_pr run: | response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "🧞‍♂️ PR 드리는 지니가 왔습니다\n[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}](${{ github.event.pull_request.html_url }})\n${{ github.event.pull_request.user.login }}님이 생성했어요." + "text": "*:남성_지니: PR 드리는 지니가 왔습니다~*\n*<${{ github.event.pull_request.html_url }}|[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}]>*\n${{ github.event.pull_request.user.login }}님이 생성했어요." }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV echo $slack_ts > slack_ts.txt @@ -46,7 +46,7 @@ jobs: slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') if [ "$slack_username" != "null" ]; then response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "🔔 리뷰 요청이 도착했습니다: @'$slack_username'" + "text": "*🔔 리뷰 요청이 도착했습니다*: @'$slack_username'" }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV echo $slack_ts > slack_ts.txt From 4d7951395ea2689017f999d540668a64e2a26593 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:00:39 +0900 Subject: [PATCH 11/23] fix --- .github/workflows/slack-notify.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 1b58c404..042f61d1 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -32,7 +32,7 @@ jobs: id: slack_pr run: | response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "*:남성_지니: PR 드리는 지니가 왔습니다~*\n*<${{ github.event.pull_request.html_url }}|[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}]>*\n${{ github.event.pull_request.user.login }}님이 생성했어요." + "text": "*🧞‍♂️ PR 드리는 지니가 왔습니다~*\n*<${{ github.event.pull_request.html_url }}|[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}]>*\n${{ github.event.pull_request.user.login }}님이 생성했어요." }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV echo $slack_ts > slack_ts.txt From 88a0e091f03e558a7335abc9767fb93f537b35be Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:16:18 +0900 Subject: [PATCH 12/23] fix --- .github/workflows/slack-notify.yml | 41 ++++++++++++++---------------- 1 file changed, 19 insertions(+), 22 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 042f61d1..174fc042 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -21,11 +21,14 @@ jobs: run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - name: Cache Slack message timestamp - if: ${{ env.event_type == 'pull_request' }} - uses: actions/cache@v2 - with: - path: slack_ts.txt - key: slack-ts-${{ github.event.pull_request.number }} + if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + id: cache_slack_ts + run: | + if [ -f slack_ts_${{ github.event.pull_request.number }}.txt ]; then + echo "slack_ts=$(cat slack_ts_${{ github.event.pull_request.number }}.txt)" >> $GITHUB_ENV + else + echo "slack_ts=" >> $GITHUB_ENV + fi - name: Send notification for PR if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} @@ -34,8 +37,9 @@ jobs: response=$(curl -X POST -H 'Content-type: application/json' --data '{ "text": "*🧞‍♂️ PR 드리는 지니가 왔습니다~*\n*<${{ github.event.pull_request.html_url }}|[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}]>*\n${{ github.event.pull_request.user.login }}님이 생성했어요." }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) - echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV - echo $slack_ts > slack_ts.txt + slack_ts=$(echo $response | jq -r '.ts') + echo "slack_ts=$slack_ts" >> $GITHUB_ENV + echo $slack_ts > slack_ts_${{ github.event.pull_request.number }}.txt env: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} @@ -45,11 +49,9 @@ jobs: reviewer=${{ github.event.requested_reviewer.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') if [ "$slack_username" != "null" ]; then - response=$(curl -X POST -H 'Content-type: application/json' --data '{ + curl -X POST -H 'Content-type: application/json' --data '{ "text": "*🔔 리뷰 요청이 도착했습니다*: @'$slack_username'" - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) - echo "slack_ts=$(echo $response | jq -r '.ts')" >> $GITHUB_ENV - echo $slack_ts > slack_ts.txt + }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} else echo "Reviewer not found in mapping: $reviewer" fi @@ -58,17 +60,12 @@ jobs: - name: Restore Slack message timestamp if: ${{ env.event_type == 'issue_comment' || env.event_type == 'pull_request_review' }} - id: restore_ts - uses: actions/cache@v2 - with: - path: slack_ts.txt - key: slack-ts-${{ github.event.issue.number || github.event.pull_request.number }} - restore-keys: | - slack-ts- - - - name: Load Slack message timestamp - if: ${{ (env.event_type == 'issue_comment' || env.event_type == 'pull_request_review') && steps.restore_ts.outputs.cache-hit == 'true' }} - run: echo "SLACK_MESSAGE_TS=$(cat slack_ts.txt)" >> $GITHUB_ENV + run: | + if [ -f slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt ]; then + echo "SLACK_MESSAGE_TS=$(cat slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt)" >> $GITHUB_ENV + else + echo "SLACK_MESSAGE_TS=" >> $GITHUB_ENV + fi - name: Send notification for comment if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} From d1dd3264e232ecab3dc9492eca8716713330da03 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:20:02 +0900 Subject: [PATCH 13/23] fix --- .github/workflows/slack-notify.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 174fc042..c1dc649d 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -35,8 +35,8 @@ jobs: id: slack_pr run: | response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "*🧞‍♂️ PR 드리는 지니가 왔습니다~*\n*<${{ github.event.pull_request.html_url }}|[sambad#${{ github.event.pull_request.number }}] [${{ github.event.pull_request.title }}]>*\n${{ github.event.pull_request.user.login }}님이 생성했어요." - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}) + "text": "*🧞‍♂️ PR 드리는 지니가 왔습니다~*\n*<'"${{ github.event.pull_request.html_url }}"'|[sambad#'"${{ github.event.pull_request.number }}"'] [${{ github.event.pull_request.title }}]>*\n${{ github.event.pull_request.user.login }}님이 생성했어요." + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") slack_ts=$(echo $response | jq -r '.ts') echo "slack_ts=$slack_ts" >> $GITHUB_ENV echo $slack_ts > slack_ts_${{ github.event.pull_request.number }}.txt @@ -51,7 +51,7 @@ jobs: if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ "text": "*🔔 리뷰 요청이 도착했습니다*: @'$slack_username'" - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" else echo "Reviewer not found in mapping: $reviewer" fi @@ -75,8 +75,8 @@ jobs: if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ "text": "@'$slack_username'님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", - "thread_ts": "${{ env.SLACK_MESSAGE_TS }}" - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} + "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" else echo "Commenter not found in mapping: $commenter" fi @@ -91,8 +91,8 @@ jobs: if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ "text": "✅ @'$slack_username'님이 승인하셨어요 🎉", - "thread_ts": "${{ env.SLACK_MESSAGE_TS }}" - }' ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} + "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" else echo "Reviewer not found in mapping: $reviewer" fi From 0b29639a5aff53ba5dae23e84c39fbab57f0b2b0 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:22:11 +0900 Subject: [PATCH 14/23] fix --- .github/workflows/slack-notify.yml | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index c1dc649d..2d597304 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -68,6 +68,24 @@ jobs: fi - name: Send notification for comment + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} + run: | + commenter=${{ github.event.comment.user.login }} + slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') + if [ "$slack_username" != "null" ]; then + response=$(curl -X POST -H 'Content-type: application/json' --data '{ + "text": "@'$slack_username'님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}" + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") + slack_ts=$(echo $response | jq -r '.ts') + echo "slack_ts=$slack_ts" >> $GITHUB_ENV + echo $slack_ts > slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt + else + echo "Commenter not found in mapping: $commenter" + fi + env: + SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} + + - name: Send notification for comment in thread if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} @@ -89,12 +107,4 @@ jobs: reviewer=${{ github.event.review.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') if [ "$slack_username" != "null" ]; then - curl -X POST -H 'Content-type: application/json' --data '{ - "text": "✅ @'$slack_username'님이 승인하셨어요 🎉", - "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" - }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" - else - echo "Reviewer not found in mapping: $reviewer" - fi - env: - SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} + curl -X POST - From 8ef33941aced0be4c2b5ca358d3fead9c768b558 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:24:46 +0900 Subject: [PATCH 15/23] fix --- .github/workflows/slack-notify.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 2d597304..0fb32a10 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -50,7 +50,7 @@ jobs: slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ - "text": "*🔔 리뷰 요청이 도착했습니다*: @'$slack_username'" + "text": "*🔔 리뷰 요청이 도착했습니다*: <@'$slack_username'>" }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" else echo "Reviewer not found in mapping: $reviewer" @@ -74,7 +74,7 @@ jobs: slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "@'$slack_username'님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}" + "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}" }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") slack_ts=$(echo $response | jq -r '.ts') echo "slack_ts=$slack_ts" >> $GITHUB_ENV @@ -92,7 +92,7 @@ jobs: slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then curl -X POST -H 'Content-type: application/json' --data '{ - "text": "@'$slack_username'님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", + "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" else From 10ffa2a2cb10237e745d020393dde6b05b5c79cf Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:26:43 +0900 Subject: [PATCH 16/23] fix --- .github/workflows/slack-notify.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 0fb32a10..068f7756 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -106,5 +106,4 @@ jobs: run: | reviewer=${{ github.event.review.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') - if [ "$slack_username" != "null" ]; then - curl -X POST - + if From 86eff17baea4c73c2b9b9b57a77d1332aee3c31d Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:30:07 +0900 Subject: [PATCH 17/23] fix --- .github/workflows/slack-notify.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 068f7756..7992a44d 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -74,7 +74,8 @@ jobs: slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then response=$(curl -X POST -H 'Content-type: application/json' --data '{ - "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}" + "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", + "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") slack_ts=$(echo $response | jq -r '.ts') echo "slack_ts=$slack_ts" >> $GITHUB_ENV @@ -105,5 +106,4 @@ jobs: if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} run: | reviewer=${{ github.event.review.user.login }} - slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') - if + slack_username=$(cat .github/user-mapping.json | jq -r From 4d604b3e5a8e2723c703d7e2471e588b2555a6c0 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:36:31 +0900 Subject: [PATCH 18/23] fix --- .github/workflows/slack-notify.yml | 36 +++++++++++++++++++----------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index 7992a44d..e07c18bd 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -59,7 +59,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Restore Slack message timestamp - if: ${{ env.event_type == 'issue_comment' || env.event_type == 'pull_request_review' }} + id: restore_slack_ts run: | if [ -f slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt ]; then echo "SLACK_MESSAGE_TS=$(cat slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt)" >> $GITHUB_ENV @@ -67,35 +67,35 @@ jobs: echo "SLACK_MESSAGE_TS=" >> $GITHUB_ENV fi - - name: Send notification for comment - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} + - name: Send notification for comment in thread + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then - response=$(curl -X POST -H 'Content-type: application/json' --data '{ + curl -X POST -H 'Content-type: application/json' --data '{ "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" - }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") - slack_ts=$(echo $response | jq -r '.ts') - echo "slack_ts=$slack_ts" >> $GITHUB_ENV - echo $slack_ts > slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" else echo "Commenter not found in mapping: $commenter" fi env: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - name: Send notification for comment in thread - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} + - name: Send notification for comment without thread + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then - curl -X POST -H 'Content-type: application/json' --data '{ + response=$(curl -X POST -H 'Content-type: application/json' --data '{ "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" - }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") + slack_ts=$(echo $response | jq -r '.ts') + echo "slack_ts=$slack_ts" >> $GITHUB_ENV + echo $slack_ts > slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt else echo "Commenter not found in mapping: $commenter" fi @@ -106,4 +106,14 @@ jobs: if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} run: | reviewer=${{ github.event.review.user.login }} - slack_username=$(cat .github/user-mapping.json | jq -r + slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') + if [ "$slack_username" != "null" ]; then + curl -X POST -H 'Content-type: application/json' --data '{ + "text": "<@'$slack_username'>님이 PR을 승인했습니다 🎉", + "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" + else + echo "Reviewer not found in mapping: $reviewer" + fi + env: + SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} From ec4213c45bf6d7f777ad5e0f1ab17fd4959f0eb0 Mon Sep 17 00:00:00 2001 From: Doeunnkimm Date: Tue, 25 Jun 2024 23:42:12 +0900 Subject: [PATCH 19/23] fix --- .github/workflows/slack-notify.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index e07c18bd..f888de3a 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -62,40 +62,40 @@ jobs: id: restore_slack_ts run: | if [ -f slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt ]; then + cat slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt echo "SLACK_MESSAGE_TS=$(cat slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt)" >> $GITHUB_ENV else echo "SLACK_MESSAGE_TS=" >> $GITHUB_ENV fi - - name: Send notification for comment in thread - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} + - name: Send notification for comment + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then - curl -X POST -H 'Content-type: application/json' --data '{ - "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", - "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" - }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" + response=$(curl -X POST -H 'Content-type: application/json' --data '{ + "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}" + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") + slack_ts=$(echo $response | jq -r '.ts') + echo "slack_ts=$slack_ts" >> $GITHUB_ENV + echo $slack_ts > slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt else echo "Commenter not found in mapping: $commenter" fi env: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - - name: Send notification for comment without thread - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} + - name: Send notification for comment in thread + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') if [ "$slack_username" != "null" ]; then - response=$(curl -X POST -H 'Content-type: application/json' --data '{ + curl -X POST -H 'Content-type: application/json' --data '{ "text": "<@'$slack_username'>님이 코멘트를 달았습니다 💌:\n${{ github.event.comment.body }}", "thread_ts": "'${{ env.SLACK_MESSAGE_TS }}'" - }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}") - slack_ts=$(echo $response | jq -r '.ts') - echo "slack_ts=$slack_ts" >> $GITHUB_ENV - echo $slack_ts > slack_ts_${{ github.event.issue.number || github.event.pull_request.number }}.txt + }' https://slack.com/api/chat.postMessage -H "Authorization: Bearer ${{ secrets.SLACK_BOT_ACCESS_TOKEN }}" else echo "Commenter not found in mapping: $commenter" fi From 70e44e01c1656f34d63a141f32bc08f8c44c73f2 Mon Sep 17 00:00:00 2001 From: semnil5202 Date: Wed, 26 Jun 2024 00:49:25 +0900 Subject: [PATCH 20/23] =?UTF-8?q?chore:=20env.event=5Ftype=20->=20github.e?= =?UTF-8?q?vent=5Fname=20=EC=9D=BC=EA=B4=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit tag: github.event_name --- .github/workflows/slack-notify.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index f888de3a..a921f451 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -21,7 +21,7 @@ jobs: run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - name: Cache Slack message timestamp - if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize')}} id: cache_slack_ts run: | if [ -f slack_ts_${{ github.event.pull_request.number }}.txt ]; then @@ -31,7 +31,7 @@ jobs: fi - name: Send notification for PR - if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} id: slack_pr run: | response=$(curl -X POST -H 'Content-type: application/json' --data '{ @@ -44,7 +44,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for review request - if: ${{ env.event_type == 'pull_request' && github.event.action == 'review_requested' }} + if: ${{ github.event_name == 'pull_request' && github.event.action == 'review_requested' }} run: | reviewer=${{ github.event.requested_reviewer.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') @@ -69,7 +69,7 @@ jobs: fi - name: Send notification for comment - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} + if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -87,7 +87,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for comment in thread - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -103,7 +103,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for approval - if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} run: | reviewer=${{ github.event.review.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') From 0893965f4c1eb2737866d34c178f9947a5a8f3a1 Mon Sep 17 00:00:00 2001 From: semnil5202 Date: Wed, 26 Jun 2024 00:52:18 +0900 Subject: [PATCH 21/23] =?UTF-8?q?chore:=20commit=2070e44e01c1656f34d63a141?= =?UTF-8?q?f32bc08f8c44c73f2=20=EB=A1=A4=EB=B0=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/slack-notify.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index a921f451..f888de3a 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -21,7 +21,7 @@ jobs: run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - name: Cache Slack message timestamp - if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize')}} + if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} id: cache_slack_ts run: | if [ -f slack_ts_${{ github.event.pull_request.number }}.txt ]; then @@ -31,7 +31,7 @@ jobs: fi - name: Send notification for PR - if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} id: slack_pr run: | response=$(curl -X POST -H 'Content-type: application/json' --data '{ @@ -44,7 +44,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for review request - if: ${{ github.event_name == 'pull_request' && github.event.action == 'review_requested' }} + if: ${{ env.event_type == 'pull_request' && github.event.action == 'review_requested' }} run: | reviewer=${{ github.event.requested_reviewer.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') @@ -69,7 +69,7 @@ jobs: fi - name: Send notification for comment - if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -87,7 +87,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for comment in thread - if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -103,7 +103,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for approval - if: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} run: | reviewer=${{ github.event.review.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') From 9b8d592933ac3c87ba94f04a8136a47623ba11ce Mon Sep 17 00:00:00 2001 From: semnil5202 Date: Wed, 26 Jun 2024 01:05:44 +0900 Subject: [PATCH 22/23] fix --- .github/workflows/slack-notify.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index f888de3a..a921f451 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -21,7 +21,7 @@ jobs: run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - name: Cache Slack message timestamp - if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize')}} id: cache_slack_ts run: | if [ -f slack_ts_${{ github.event.pull_request.number }}.txt ]; then @@ -31,7 +31,7 @@ jobs: fi - name: Send notification for PR - if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} id: slack_pr run: | response=$(curl -X POST -H 'Content-type: application/json' --data '{ @@ -44,7 +44,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for review request - if: ${{ env.event_type == 'pull_request' && github.event.action == 'review_requested' }} + if: ${{ github.event_name == 'pull_request' && github.event.action == 'review_requested' }} run: | reviewer=${{ github.event.requested_reviewer.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') @@ -69,7 +69,7 @@ jobs: fi - name: Send notification for comment - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} + if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -87,7 +87,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for comment in thread - if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -103,7 +103,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for approval - if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} run: | reviewer=${{ github.event.review.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') From ca855983b19cad2e6c23871dfd714dc7121f79db Mon Sep 17 00:00:00 2001 From: semnil5202 Date: Wed, 26 Jun 2024 01:07:04 +0900 Subject: [PATCH 23/23] rollback: 9b8d592 --- .github/workflows/slack-notify.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/slack-notify.yml b/.github/workflows/slack-notify.yml index a921f451..f888de3a 100644 --- a/.github/workflows/slack-notify.yml +++ b/.github/workflows/slack-notify.yml @@ -21,7 +21,7 @@ jobs: run: echo "event_type=${{ github.event_name }}" >> $GITHUB_ENV - name: Cache Slack message timestamp - if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize')}} + if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} id: cache_slack_ts run: | if [ -f slack_ts_${{ github.event.pull_request.number }}.txt ]; then @@ -31,7 +31,7 @@ jobs: fi - name: Send notification for PR - if: ${{ github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} + if: ${{ env.event_type == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened' || github.event.action == 'synchronize') }} id: slack_pr run: | response=$(curl -X POST -H 'Content-type: application/json' --data '{ @@ -44,7 +44,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for review request - if: ${{ github.event_name == 'pull_request' && github.event.action == 'review_requested' }} + if: ${{ env.event_type == 'pull_request' && github.event.action == 'review_requested' }} run: | reviewer=${{ github.event.requested_reviewer.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]') @@ -69,7 +69,7 @@ jobs: fi - name: Send notification for comment - if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS == '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -87,7 +87,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for comment in thread - if: ${{ github.event_name == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ env.event_type == 'issue_comment' && env.SLACK_MESSAGE_TS != '' }} run: | commenter=${{ github.event.comment.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg commenter "$commenter" '.[$commenter]') @@ -103,7 +103,7 @@ jobs: SLACK_BOT_ACCESS_TOKEN: ${{ secrets.SLACK_BOT_ACCESS_TOKEN }} - name: Send notification for approval - if: ${{ github.event_name == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} + if: ${{ env.event_type == 'pull_request_review' && github.event.review.state == 'approved' && env.SLACK_MESSAGE_TS != '' }} run: | reviewer=${{ github.event.review.user.login }} slack_username=$(cat .github/user-mapping.json | jq -r --arg reviewer "$reviewer" '.[$reviewer]')