Conversation
There was a problem hiding this comment.
Pull request overview
Adds an event-driven GitHub Actions workflow that posts interactive Lark (Feishu) bot notifications, using a Deno/TypeScript script to transform the github context payload into a Lark card.
Changes:
- Introduces
.github/workflows/Lark-notification.ymlto trigger on common repo events and send Lark notifications. - Adds
.github/scripts/transform-message.tsto format GitHub event payloads into a Lark interactive card payload.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| .github/workflows/Lark-notification.yml | New workflow to serialize GitHub event context and send it to Lark via Open-Source-Bazaar/feishu-action. |
| .github/scripts/transform-message.ts | New Deno script that maps GitHub event types to Lark card titles/content and outputs a card payload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+15
to
+18
|
|
||
| jobs: | ||
| send-Lark-message: | ||
| runs-on: ubuntu-latest |
Comment on lines
+31
to
+36
| YAML=$(printf '%s' "$GITHUB_CONTEXT" | deno run --allow-all .github/scripts/transform-message.ts) | ||
| { | ||
| echo 'content<<EOF' | ||
| echo "$YAML" | ||
| echo 'EOF' | ||
| } >> "$GITHUB_OUTPUT" |
Comment on lines
+100
to
+103
| const commitUrl = | ||
| head_commit?.url || `${server_url}/${repository}/tree/${ref_name}`; | ||
| const commitMessage = | ||
| head_commit?.message || 'Create/Delete/Update Branch (No head commit)'; |
Comment on lines
+51
to
+72
| const sanitizeMarkdown = (text: string): string => | ||
| text | ||
| // Remove code blocks | ||
| .replace(/```[\s\S]*?```/g, '[代码块]') | ||
| // Remove inline code | ||
| .replace(/`[^`]+`/g, (match) => match.slice(1, -1)) | ||
| // Convert images to link text | ||
| .replace(/!\[([^\]]*)\]\(([^)]+)\)/g, '🖼️ [$1]($2)') | ||
| // Convert ### headers to bold | ||
| .replace(/^###\s+(.+)$/gm, '**$1**') | ||
| // Convert ## headers to bold | ||
| .replace(/^##\s+(.+)$/gm, '**$1**') | ||
| // Convert # headers to bold | ||
| .replace(/^#\s+(.+)$/gm, '**$1**') | ||
| // Remove HTML comments | ||
| .replace(/<!--[\s\S]*?-->/g, '') | ||
| // Remove HTML tags (keep content) | ||
| .replace(/<[^>]+>/g, '') | ||
| // Remove excess empty lines | ||
| .replace(/\n{3,}/g, '\n\n') | ||
| // Truncate long content | ||
| .slice(0, 800) + (text.length > 800 ? '\n...' : ''); |
Comment on lines
+77
to
+80
| interface LarkMessageElement { | ||
| tag: string; | ||
| content: string | [object, object][]; | ||
| } |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.