chore: notify Feishu when GitHub Project draft items change#541
chore: notify Feishu when GitHub Project draft items change#541qiongyu1999 merged 3 commits intomainfrom
Conversation
Add workflow and script to send Feishu card notifications when project board items are created, edited (status/assignee/priority change), archived, deleted, or restored. Uses GraphQL to fetch full item details including draft title, body, assignees, and custom fields. Made-with: Cursor
📝 WalkthroughWalkthroughAdds a GitHub Actions workflow and a Node.js notification script to send Feishu interactive-card notifications for GitHub Projects v2 item events; includes small local identifier renames in desktop, launchd bootstrap, and an e2e test file. Changes
Sequence DiagramsequenceDiagram
participant GHProjects as GH Projects v2
participant GHA as GitHub Actions (Workflow)
participant Script as Notifier Script (Node)
participant GraphQL as GitHub GraphQL API
participant Feishu as Feishu Webhook
GHProjects->>GHA: Emit item event (created/edited/archived/deleted/restored)
GHA->>GHA: Sparse-checkout `scripts/notify` & create App token
GHA->>Script: Execute `node scripts/notify/feishu-project-notify.mjs` (env + token)
Script->>GraphQL: Query item details (node ID) using App token
GraphQL-->>Script: Return item metadata and fields
Script->>Script: Build change summary & Feishu card payload
Script->>Feishu: POST interactive card to webhook URL
Feishu-->>Script: Respond (success/error)
Script-->>GHA: Exit with status
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 69bc0bd55e
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/workflows/feishu-project-item-notify.yml:
- Around line 3-5: The workflow's on: trigger uses the unsupported
projects_v2_item event (projects_v2_item with types [created, edited, archived,
deleted, restored]); remove or replace this trigger and instead either (A) set
up a repository webhook to forward projects_v2_item to an external endpoint and
use repository_dispatch to kick the workflow, (B) change the workflow trigger to
a supported event such as issues or pull_request and then have the job call the
GitHub REST/GraphQL API to query/update project v2 items, or (C) trigger via
schedule or manual workflow_dispatch and perform project v2 operations via
API—update the workflow header accordingly and document which approach you
choose.
In `@scripts/notify/feishu-project-notify.mjs`:
- Around line 215-236: The file has Biome formatting/whitespace/line-break
issues in the block around variables like contentAssignees, fieldAssignees,
assigneesText, status, priority, labels, itemUrl (buildProjectUrl), changeInfo
(buildStatusChangeText) and the actionText/headerColor extraction from
ACTION_CONFIG; run "biome format --write" on
scripts/notify/feishu-project-notify.mjs (or the repo root) to apply the
formatter and re-save the file so the pipeline passes formatting checks.
- Line 32: The declared constant repo (const repo = process.env.REPO ?? "") in
the script is unused and causing lint failures; either remove that declaration
entirely or start using repo in the notification payload (e.g., include it in
the message/body where other env vars are referenced). If you remove it, also
remove REPO from the workflow/env block to keep CI config clean. Update the
feishu-project-notify.mjs file by deleting the unused const repo line or wiring
repo into the notification construction, and mirror the removal in the workflow
env if unused.
- Around line 187-192: The buildProjectUrl function currently assumes org-owned
projects; update it to choose the correct URL pattern based on ownership by
reading a new boolean flag (e.g., IS_ORG_PROJECT from env or workflow input) and
using `/orgs/${orgOrUser}/projects/${projectNumber}` when true and
`/users/${orgOrUser}/projects/${projectNumber}` when false; ensure you reference
the existing symbols buildProjectUrl, orgOrUser and projectNumber and wire
IS_ORG_PROJECT into the script (or, alternatively, implement a fallback that
attempts both patterns) so user-owned projects resolve correctly.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 8329b132-144c-4071-a835-6dea2e1e11d4
📒 Files selected for processing (2)
.github/workflows/feishu-project-item-notify.ymlscripts/notify/feishu-project-notify.mjs
…-oauth spec Made-with: Cursor
Made-with: Cursor
Summary
projects_v2_item事件(created / edited / archived / deleted / restored)Prerequisites
nexu-palGitHub App 已添加organization_projects: read权限ISSUE_SYNC_FEISHU_BOT_WEBHOOKsecret 已配置New files
.github/workflows/feishu-project-item-notify.yml— workflowscripts/notify/feishu-project-notify.mjs— 飞书通知脚本Test plan
Made with Cursor
Summary by CodeRabbit
New Features
Refactor