|
| 1 | +name: Slack BlockKit — Sonar / Failure test |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + assignee: |
| 7 | + description: '담당자 (optional)' |
| 8 | + required: false |
| 9 | + message: |
| 10 | + description: '보낼 메시지 (optional, 기본값은 예제 텍스트)' |
| 11 | + required: false |
| 12 | + default: | |
| 13 | + :x:[AndroidTV:tv:] Sonar Check 실패!! ㅠㅠ |
| 14 | + [QE-374] 광고 플레이어 > 컴포넌트 ON > 하단 방향키 클릭 시 컴포넌트 OFF 안 됨 (#384) README.md app benchmark build build-logic build.gradle.kts cjhv_tvingstick.keystore core feature flipper-buildvariant-implement.gradle flipperandroidnoop gaudioLab git-hook-files git-hook-files-script.gradle gradle gradle-build-variant.gradle gradle.properties gradlew gradlew.bat sentry.properties settings.gradle.kts tvUtils [QE-374] 광고 플레이어 컨트롤러 ON 상태에서 하단 방향키로 OFF 처리 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> README.md app benchmark build build-logic build.gradle.kts cjhv_tvingstick.keystore core feature flipper-buildvariant-implement.gradle flipperandroidnoop gaudioLab git-hook-files git-hook-files-script.gradle gradle gradle-build-variant.gradle gradle.properties gradlew gradlew.bat sentry.properties settings.gradle.kts tvUtils [QE-334] 티빙톡 에러 문구 가로 Max width 319 → 390 변경 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> README.md app benchmark build build-logic build.gradle.kts cjhv_tvingstick.keystore core feature flipper-buildvariant-implement.gradle flipperandroidnoop gaudioLab git-hook-files git-hook-files-script.gradle gradle gradle-build-variant.gradle gradle.properties gradlew gradlew.bat sentry.properties settings.gradle.kts tvUtils Revert "[QE-334] 티빙톡 에러 문구 가로 Max width 319 → 390 변경" This reverts commit 6397d8d2988f09b7c0fc9befa707b69dc850912b. --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> |
| 15 | + 브랜치 : release/26.11.01 |
| 16 | + 담당자 : |
| 17 | +
|
| 18 | +jobs: |
| 19 | + send-blockkit: |
| 20 | + runs-on: ubuntu-latest |
| 21 | + steps: |
| 22 | + - name: Prepare payload and send Slack Block Kit message |
| 23 | + env: |
| 24 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 25 | + REPO: ${{ github.repository }} |
| 26 | + ACTOR: ${{ github.actor }} |
| 27 | + RUN_ID: ${{ github.run_id }} |
| 28 | + REF: ${{ github.ref }} |
| 29 | + # workflow_dispatch inputs |
| 30 | + ASSIGNEE: ${{ github.event.inputs.assignee }} |
| 31 | + INPUT_MESSAGE: ${{ github.event.inputs.message }} |
| 32 | + run: | |
| 33 | + set -euo pipefail |
| 34 | +
|
| 35 | + if [ -z "${SLACK_WEBHOOK_URL:-}" ]; then |
| 36 | + echo "ERROR: SLACK_WEBHOOK_URL secret is not set. Add it to repo secrets." |
| 37 | + exit 1 |
| 38 | + fi |
| 39 | +
|
| 40 | + # Compute branch name (fallback) |
| 41 | + BRANCH="${REF##*/}" |
| 42 | + # Use provided message or fallback to default (INPUT_MESSAGE already contains default) |
| 43 | + MSG="${INPUT_MESSAGE:-No message provided.}" |
| 44 | + # Trim leading/trailing whitespace |
| 45 | + MSG="$(echo "$MSG" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')" |
| 46 | +
|
| 47 | + # Truncate if too long (Slack block limits). Keep safety margin. |
| 48 | + MAX_LEN=3000 |
| 49 | + if [ "${#MSG}" -gt "$MAX_LEN" ]; then |
| 50 | + MSG="${MSG:0:$MAX_LEN} |
| 51 | +(…truncated)" |
| 52 | + fi |
| 53 | + |
| 54 | + # Build Block Kit JSON safely using jq (install if missing) |
| 55 | + if ! command -v jq >/dev/null 2>&1; then |
| 56 | + sudo apt-get update -y |
| 57 | + sudo apt-get install -y jq |
| 58 | + fi |
| 59 | + |
| 60 | + HEADER_TEXT="⛔ Sonar Check 실패" |
| 61 | + SUBTITLE="*레포:* \`$REPO\` • *브랜치:* \`$BRANCH\` • *Trigger:* \`$ACTOR\`" |
| 62 | + if [ -n "${ASSIGNEE:-}" ]; then |
| 63 | + SUBTITLE="$SUBTITLE • *담당자:* \`$ASSIGNEE\`" |
| 64 | + fi |
| 65 | + |
| 66 | + BRANCH_URL="https://github.com/${REPO}/tree/${BRANCH}" |
| 67 | + RUN_URL="https://github.com/${REPO}/actions/runs/${RUN_ID}" |
| 68 | + |
| 69 | + # Build blocks |
| 70 | + BLOCKS=$(jq -nc \ |
| 71 | + --arg header "$HEADER_TEXT" \ |
| 72 | + --arg subtitle "$SUBTITLE" \ |
| 73 | + --arg run_url "$RUN_URL" \ |
| 74 | + --arg branch_url "$BRANCH_URL" \ |
| 75 | + --arg msg "$MSG" \ |
| 76 | + '[ |
| 77 | + { "type":"header", "text": { "type":"plain_text", "text": $header, "emoji": true } }, |
| 78 | + { "type":"section", "text": { "type":"mrkdwn", "text": $subtitle } }, |
| 79 | + { |
| 80 | + "type": "actions", |
| 81 | + "elements": [ |
| 82 | + { "type":"button", "text": { "type":"plain_text", "text":"🔎 Actions Run 보기", "emoji": true }, "url": $run_url }, |
| 83 | + { "type":"button", "text": { "type":"plain_text", "text":"🌿 브랜치 보기", "emoji": true }, "url": $branch_url } |
| 84 | + ] |
| 85 | + }, |
| 86 | + { "type":"divider" }, |
| 87 | + { |
| 88 | + "type":"section", |
| 89 | + "text": { "type":"mrkdwn", "text": "*Details*\n```" + ($msg) + "```" } |
| 90 | + }, |
| 91 | + { |
| 92 | + "type":"context", |
| 93 | + "elements": [ |
| 94 | + { "type":"mrkdwn", "text": "자동 알림: Sonar/CI 검사 실패 알림입니다." } |
| 95 | + ] |
| 96 | + } |
| 97 | + ]') |
| 98 | + |
| 99 | + # Build final payload |
| 100 | + PAYLOAD=$(jq -nc --argjson blocks "$BLOCKS" '{ blocks: $blocks }') |
| 101 | + |
| 102 | + # Debug: print payload size and first 400 chars |
| 103 | + echo "Payload length: $(echo -n "$PAYLOAD" | wc -c) bytes" |
| 104 | + echo "Preview:" |
| 105 | + echo "$PAYLOAD" | head -c 400 |
| 106 | + echo "..." |
| 107 | + |
| 108 | + # Send to Slack |
| 109 | + curl -sS -X POST -H 'Content-type: application/json' --data "$PAYLOAD" "$SLACK_WEBHOOK_URL" || { |
| 110 | + echo "Warning: Slack webhook call failed" |
| 111 | + exit 0 |
| 112 | + } |
| 113 | + |
| 114 | + echo "Slack message sent." |
0 commit comments