-
Notifications
You must be signed in to change notification settings - Fork 524
[๐จ Design System] Slack notification on DS changes #1902
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+238
โ0
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ab53a99
ci(design-system): add Slack notification on DS changes
jungcome7 5433d91
fix(ci): fix sed delimiter conflict and theme root file handling
jungcome7 0ec99ad
fix(ci): fix Storybook URL mapping in DS notification
jungcome7 4e9cf74
fix(ci): link to story page instead of docs in DS notification
jungcome7 d5311d8
fix(ci): add permissions block to DS notification workflow
jungcome7 0591b3c
fix(ci): prevent shell injection in DS notification workflow
jungcome7 a78bf1c
chore(ci): remove redundant env vars (GITHUB_SHA, GITHUB_REPOSITORY aโฆ
jungcome7 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,238 @@ | ||
| # Design System ๋ณ๊ฒฝ ์ Slack ์๋ฆผ์ ๋ณด๋ด๋ ์ํฌํ๋ก์ฐ | ||
| # | ||
| # ํ๋ฆ: | ||
| # 1. develop push ์ packages/design-system/ ํ์ ํ์ผ ๋ณ๊ฒฝ ๊ฐ์ง | ||
| # 2. ๋ณ๊ฒฝ๋ ์ปดํฌ๋ํธ/foundation ์ด๋ฆ ์ถ์ถ (kebab-case โ DSPascalCase) | ||
| # 3. Claude API๋ก diff ์์ฝ ์์ฑ | ||
| # 4. Slack Block Kit ํ์์ผ๋ก ์๋ฆผ ์ ์ก | ||
| # | ||
| # Slack ๋ฉ์์ง ์์: | ||
| # [Extension DS] DSColor, DSTypography ์ ๋ฐ์ดํธ | ||
| # ๐ง *DSColor*: dark/light ํ ๋ง ํ ํฐ ๊ฐ ๋ณ๊ฒฝ | ||
| # ๐ Storybook | #1901 | ||
| name: Design System Change Notification | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - develop | ||
| paths: | ||
| - "packages/design-system/src/**" | ||
| workflow_dispatch: | ||
|
|
||
| jobs: | ||
| notify: | ||
| name: Notify Slack on Design System changes | ||
| runs-on: ubuntu-24.04 | ||
| timeout-minutes: 5 | ||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: | ||
| fetch-depth: 0 | ||
|
|
||
| # Step 1: ๋ณ๊ฒฝ๋ ์ปดํฌ๋ํธ ์ด๋ฆ ์ถ์ถ | ||
| - name: Extract component info | ||
| id: components | ||
| run: | | ||
| BASE_SHA=${{ github.event.before }} | ||
| HEAD_SHA=${{ github.sha }} | ||
| STORYBOOK_BASE="https://chainapsis.github.io/keplr-wallet/storybook/?path=" | ||
|
|
||
| # ๋ณ๊ฒฝ๋ ๋๋ ํ ๋ฆฌ ๋ชฉ๋ก (foundation/color, foundation/typography ๋ฑ) | ||
| # sed ๊ตฌ๋ถ์์ alternation | ์ถฉ๋ ๋ฐฉ์ง๋ฅผ ์ํด ์นดํ ๊ณ ๋ฆฌ๋ณ ๋ณ๋ ํจํด ์ฌ์ฉ | ||
| CHANGED_DIRS=$(git diff --name-only $BASE_SHA...$HEAD_SHA -- 'packages/design-system/src/' \ | ||
| | grep -E '(components|foundation|theme)/' \ | ||
| | sed -E 's|.*/components/([^/]+)/.*|components/\1|; s|.*/foundation/([^/]+)/.*|foundation/\1|; s|.*/theme/([^/]+)/.*|theme/\1|; s|.*/theme/[^/]+$|theme|' \ | ||
| | sort -u) | ||
|
|
||
| # DSPascalCase ์ด๋ฆ ๋ชฉ๋ก (kebab-case โ DSPascalCase) | ||
| COMPONENTS=$(echo "$CHANGED_DIRS" \ | ||
| | while read dir_path; do | ||
| echo "$dir_path" | sed -E 's|.*/||' | sed -E 's/-(.)/\U\1/g; s/^(.)/DS\U\1/' | ||
| done \ | ||
| | paste -sd ',' - | sed 's/,/, /g') | ||
| echo "names=${COMPONENTS:-Unknown}" >> $GITHUB_OUTPUT | ||
|
|
||
| # DSName|storybook_url ๋งคํ ํ์ผ ์์ฑ | ||
| if [ -z "$CHANGED_DIRS" ]; then | ||
| > /tmp/component_urls.txt | ||
| else | ||
| echo "$CHANGED_DIRS" | while read dir_path; do | ||
| category=$(echo "$dir_path" | cut -d/ -f1) | ||
| dir_name=$(echo "$dir_path" | cut -d/ -f2) | ||
| ds_name=$(echo "$dir_name" | sed -E 's/-(.)/\U\1/g; s/^(.)/DS\U\1/') | ||
| # Storybook URL: /story/foundations-color--color | ||
| # category ๋งคํ: foundation โ foundations, components โ components, theme โ foundations | ||
| case "$category" in | ||
| foundation) sb_category="foundations" ;; | ||
| theme) sb_category="foundations" ;; | ||
| *) sb_category="$category" ;; | ||
| esac | ||
| sb_name="${dir_name:-theme}" | ||
| echo "${ds_name}|${STORYBOOK_BASE}/story/${sb_category}-${sb_name}--${sb_name}" | ||
| done > /tmp/component_urls.txt | ||
| fi | ||
|
|
||
| # ์ ๊ท ์ปดํฌ๋ํธ: ๋๋ ํ ๋ฆฌ ์์ฒด๊ฐ BASE_SHA์ ์์๋ ๊ฒฝ์ฐ๋ง | ||
| NEW_COMPONENTS=$(git diff --name-status $BASE_SHA...$HEAD_SHA -- 'packages/design-system/src/' \ | ||
| | grep '^A' \ | ||
| | grep -E '(components|foundation|theme)/[^/]+/' \ | ||
| | sed -E 's|.*/components/([^/]+)/.*|components/\1|; s|.*/foundation/([^/]+)/.*|foundation/\1|; s|.*/theme/([^/]+)/.*|theme/\1|' \ | ||
| | sort -u \ | ||
| | while read dir_path; do | ||
| if ! git ls-tree -r "$BASE_SHA" -- "packages/design-system/src/${dir_path}/" 2>/dev/null | grep -q .; then | ||
| echo "$dir_path" | sed -E 's|.*/||' | sed -E 's/-(.)/\U\1/g; s/^(.)/DS\U\1/' | ||
| fi | ||
| done \ | ||
| | paste -sd ',' - | sed 's/,/, /g') | ||
| echo "new_components=${NEW_COMPONENTS}" >> $GITHUB_OUTPUT | ||
|
|
||
| echo "storybook_link=https://chainapsis.github.io/keplr-wallet/storybook/" >> $GITHUB_OUTPUT | ||
|
|
||
| # Step 2: Claude API๋ก diff ์์ฝ ์์ฑ | ||
| - name: Summarize changes with Claude | ||
| id: summary | ||
| run: | | ||
| BASE_SHA=${{ github.event.before }} | ||
| HEAD_SHA=${{ github.sha }} | ||
|
|
||
| git diff $BASE_SHA...$HEAD_SHA -- 'packages/design-system/src/' | head -500 > /tmp/diff.txt | ||
|
|
||
| DIFF_CONTENT=$(cat /tmp/diff.txt) | ||
|
|
||
| PROMPT="์๋ diff๋ฅผ ๋ถ์ํด์ ์ปดํฌ๋ํธ๋ณ ๋ณ๊ฒฝ์ฌํญ์ ์์ฝํด์ค. | ||
|
|
||
| ๋ณ๊ฒฝ๋ ์ปดํฌ๋ํธ: ${{ steps.components.outputs.names }} | ||
| ์ด ์ค ์๋ก ์ถ๊ฐ๋ ์ปดํฌ๋ํธ: ${{ steps.components.outputs.new_components }} | ||
|
|
||
| ๊ท์น: | ||
| - ์ ์ปดํฌ๋ํธ๋ ๐, ์์ ๋ ์ปดํฌ๋ํธ๋ ๐ง๋ก ์์ | ||
| - ์ปดํฌ๋ํธ๋ช ์ *bold*, ์ฝ๋ก ๋ค์ ํ์ค ์ค๋ช | ||
| - ์ฃผ์ props๋ ๋ค์ฌ์ฐ๊ธฐ ํ โข ๋ก ๋์ด (prop๋ช : ์ค๋ช ) | ||
| - ๋ฐ๋์ diff์ ์ค์ ๋ณ๊ฒฝ ๋ด์ฉ๋ง ์ฌ์ฉํ ๊ฒ | ||
| - ์๋ก /๊ฒฐ๋ก ์์ด ์ปดํฌ๋ํธ๋ณ ์์ฝ๋ง ์ถ๋ ฅ | ||
|
|
||
| ํ์ ์ฐธ๊ณ ์ฉ ์์ (์ด ๋ด์ฉ์ ๊ทธ๋๋ก ์ฐ์ง ๋ง ๊ฒ): | ||
| ๐ *DSBadge*: ๋ฑ์ง ์ปดํฌ๋ํธ ์ถ๊ฐ | ||
| โข variant: solid, outline ๋ฑ ์คํ์ผ ์ ํ | ||
| ๐ง *DSColor*: dark ํ ๋ง ํ ํฐ ๊ฐ ๋ณ๊ฒฝ | ||
| โข fill.neutral.high: gray10 โ gray200์ผ๋ก ๋ณ๊ฒฝ" | ||
|
|
||
| jq -n --arg prompt "$PROMPT" --arg diff "$DIFF_CONTENT" '{ | ||
| "model": "claude-haiku-4-5", | ||
| "max_tokens": 600, | ||
| "messages": [{ | ||
| "role": "user", | ||
| "content": ($prompt + "\n\ndiff:\n" + $diff) | ||
| }] | ||
| }' > /tmp/payload.json | ||
|
|
||
| RESPONSE=$(curl -s "https://api.anthropic.com/v1/messages" \ | ||
| -H "Content-Type: application/json" \ | ||
| -H "x-api-key: $ANTHROPIC_API_KEY" \ | ||
| -H "anthropic-version: 2023-06-01" \ | ||
| -d @/tmp/payload.json) | ||
|
|
||
| echo "Claude API Response: $RESPONSE" | ||
|
|
||
| ERROR_TYPE=$(echo "$RESPONSE" | jq -r '.error.type // empty') | ||
| if [ -n "$ERROR_TYPE" ]; then | ||
| ERROR_MSG=$(echo "$RESPONSE" | jq -r '.error.message // empty') | ||
| echo "API Error: $ERROR_TYPE - $ERROR_MSG" | ||
| SUMMARY="๋์์ธ ์์คํ ์ด ์ ๋ฐ์ดํธ๋์์ต๋๋ค." | ||
| else | ||
| SUMMARY=$(echo "$RESPONSE" | jq -r '.content[0].text // "๋์์ธ ์์คํ ์ด ์ ๋ฐ์ดํธ๋์์ต๋๋ค."' \ | ||
| | tr -d '`' \ | ||
| | sed 's/\*\*/*/g' \ | ||
| | grep -E '^(๐|๐ง| +โข)' \ | ||
| ) | ||
| fi | ||
| echo "text<<EOF" >> $GITHUB_OUTPUT | ||
| echo "$SUMMARY" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
| env: | ||
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY_FOR_DS }} | ||
|
|
||
| # Step 3: Slack Block Kit ํ์์ผ๋ก ์๋ฆผ ์ ์ก | ||
| - name: Send Slack notification | ||
| run: | | ||
| NEW_COMPONENTS="${{ steps.components.outputs.new_components }}" | ||
| ALL_COMPONENTS="${{ steps.components.outputs.names }}" | ||
| SUMMARY="${{ steps.summary.outputs.text }}" | ||
| STORYBOOK_LINK="${{ steps.components.outputs.storybook_link }}" | ||
|
|
||
| # ํค๋: ์ถ๊ฐ/์ ๋ฐ์ดํธ ๊ตฌ๋ถ | ||
| if [ -n "$NEW_COMPONENTS" ]; then | ||
| UPDATED_COMPONENTS=$(comm -23 \ | ||
| <(echo "$ALL_COMPONENTS" | tr ',' '\n' | sed 's/^ //' | sort) \ | ||
| <(echo "$NEW_COMPONENTS" | tr ',' '\n' | sed 's/^ //' | sort) \ | ||
| | paste -sd ',' - | sed 's/,/, /g') | ||
|
|
||
| if [ -n "$UPDATED_COMPONENTS" ]; then | ||
| HEADER="[Extension DS] ${NEW_COMPONENTS} ์ถ๊ฐ ยท ${UPDATED_COMPONENTS} ์ ๋ฐ์ดํธ" | ||
| else | ||
| HEADER="[Extension DS] ${NEW_COMPONENTS} ์ถ๊ฐ" | ||
| fi | ||
| else | ||
| HEADER="[Extension DS] ${ALL_COMPONENTS} ์ ๋ฐ์ดํธ" | ||
| fi | ||
|
|
||
| # ์ปดํฌ๋ํธ๋ช ์ Storybook ๋งํฌ ์ฝ์ : *DSXxx* โ *<url|DSXxx>* | ||
| while IFS='|' read -r ds_name url; do | ||
| SUMMARY=$(echo "$SUMMARY" | sed "s@\\*${ds_name}\\*@*<${url}|${ds_name}>*@g") | ||
| done < /tmp/component_urls.txt | ||
|
|
||
| MSG="$SUMMARY" | ||
|
|
||
| PR_NUMBER=$(echo "$COMMIT_MSG" | grep -oP '#\K\d+' | head -1) | ||
|
|
||
| if [ -n "$PR_NUMBER" ]; then | ||
| PR_LINK="<https://github.com/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}|#${PR_NUMBER}>" | ||
| else | ||
| COMMIT_SHORT_SHA=$(echo "$GITHUB_SHA" | cut -c1-7) | ||
| PR_LINK="<${COMMIT_URL}|${COMMIT_SHORT_SHA}>" | ||
| fi | ||
|
|
||
| jq -n \ | ||
| --arg header "$HEADER" \ | ||
| --arg content "$MSG" \ | ||
| --arg storybook_link "<${STORYBOOK_LINK}|๐ Storybook>" \ | ||
| --arg pr_link "$PR_LINK" \ | ||
| '{ | ||
| "blocks": [ | ||
| { | ||
| "type": "header", | ||
| "text": { | ||
| "type": "plain_text", | ||
| "text": $header | ||
| } | ||
| }, | ||
| { | ||
| "type": "section", | ||
| "text": { | ||
| "type": "mrkdwn", | ||
| "text": $content | ||
| } | ||
| }, | ||
| { | ||
| "type": "context", | ||
| "elements": [ | ||
| { | ||
| "type": "mrkdwn", | ||
| "text": ($storybook_link + " | " + $pr_link) | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }' > /tmp/slack_payload.json | ||
|
|
||
| curl -X POST \ | ||
| -H "Content-Type: application/json" \ | ||
| -d @/tmp/slack_payload.json \ | ||
| "$SLACK_WEBHOOK_URL" | ||
| env: | ||
| SLACK_WEBHOOK_URL: ${{ secrets.DS_NOTIFICATION_SLACK_WEBHOOK_URL }} | ||
| COMMIT_MSG: ${{ github.event.head_commit.message }} | ||
| COMMIT_URL: ${{ github.event.head_commit.url }} | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.