GitHub Action for sending notifications to Feishu (飞书)
A simple GitHub Action that allows any repository to send notifications to Feishu via webhook. This provides a unified notification mechanism across your organization, eliminating the need to duplicate notification logic in each repository.
- GitHub Composite Action: Use standard GitHub Actions syntax with version pinning
- Multiple Message Types: Support for text, rich text (post), and interactive card messages
- Simple Configuration: Just provide a webhook URL and message content
- Standardized Output: Returns status, timestamp, and response data for downstream processing
- Fast Execution: Pre-compiled JavaScript with no runtime TypeScript compilation overhead
Send a simple text message:
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: HagiCode-org/haginotifier@v1
with:
message: 'Deployment successful!'
env:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}Send a rich text message with a title:
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: HagiCode-org/haginotifier@v1
with:
message: 'The production deployment has been completed successfully.'
msg_type: 'post'
title: 'Deployment Notification'
env:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}Send an interactive card message:
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: HagiCode-org/haginotifier@v1
with:
message: 'Build #123 completed in 5 minutes'
msg_type: 'interactive'
title: 'CI/CD Pipeline Status'
env:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}Access the notification result in subsequent steps:
jobs:
notify:
runs-on: ubuntu-latest
steps:
- id: notification
uses: HagiCode-org/haginotifier@v1
with:
message: 'Test notification'
env:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}
- name: Check notification status
run: |
echo "Status: ${{ steps.notification.outputs.status }}"
echo "Timestamp: ${{ steps.notification.outputs.timestamp }}"
echo "Response: ${{ steps.notification.outputs.response }}"| Parameter | Required | Type | Description | Default |
|---|---|---|---|---|
message |
Yes | string | Notification message content | - |
msg_type |
No | string | Message type: text, post, or interactive |
text |
title |
No | string | Message title for post/interactive messages | - |
| Variable | Required | Description |
|---|---|---|
FEISHU_WEBHOOK_URL |
Yes | Feishu Webhook URL for sending notifications |
| Parameter | Type | Description |
|---|---|---|
status |
string | Notification delivery status: success or failure |
timestamp |
string | ISO 8601 timestamp of notification send attempt |
response |
string | Webhook response content or error message |
Configure the webhook URL once at the organization level, and all repositories within the organization can reuse it without managing their own webhook URL. This is the recommended approach for managing multiple repositories.
Prerequisites:
- You must be a member of a GitHub organization
- You need organization admin permissions to configure organization secrets
To configure organization-level Secret:
- Navigate to your organization's main page on GitHub
- Click on Settings tab
- In the left sidebar, select Secrets and variables > Actions
- Click New repository secret
- Name the secret
FEISHU_WEBHOOK_URL - Paste your Feishu Webhook URL as the value
- Important: Configure Access settings to select which repositories can use this secret
- Click Add secret
In consuming repositories:
jobs:
notify:
runs-on: ubuntu-latest
steps:
- uses: HagiCode-org/haginotifier@v1
with:
message: 'Your notification here'
env:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}Benefits of Organization-level Secrets:
- Configure once, use across multiple repositories
- Easier management - update the secret in one place
- Official GitHub recommended approach
- More secure with centralized control
Each repository manages its own webhook URL. This is suitable for:
- Personal accounts without organization access
- Repositories that need different webhook URLs
- Go to Settings > Secrets and variables > Actions in your repository
- Create a new secret named
FEISHU_WEBHOOK_URL - Paste your Feishu Webhook URL as the value
- Open your Feishu group chat
- Go to Group Settings > Group Chat > Chatbots > Add Robot
- Select "Custom Bot" and configure it
- Copy the Webhook URL
For production use, pin to a specific version tag instead of using @v1:
# Pin to major version (gets updates)
- uses: HagiCode-org/haginotifier@v1
# Pin to specific version (most stable)
- uses: HagiCode-org/haginotifier@v1.0.0
# Use latest (not recommended for production)
- uses: HagiCode-org/haginotifier@mainThis action has been converted from a reusable workflow to a composite action. If you were using the old reusable workflow syntax, you need to update your workflow files.
Old syntax (Reusable Workflow):
jobs:
notify:
uses: HagiCode-org/haginotifier/.github/workflows/notify.yml@main
with:
message: 'Deployment successful!'
secrets:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}
check-result:
needs: notify
runs-on: ubuntu-latest
steps:
- name: Check status
run: echo "Status: ${{ needs.notify.outputs.status }}"New syntax (Composite Action):
jobs:
notify:
runs-on: ubuntu-latest
steps:
- id: notification
uses: HagiCode-org/haginotifier@v1
with:
message: 'Deployment successful!'
env:
FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }}
- name: Check status
run: echo "Status: ${{ steps.notification.outputs.status }}"Key Changes:
- Add
runs-on: ubuntu-latestto the job - Add
steps:array - Move
secrets:toenv:under the step - Use
steps.<step-id>.outputs.<output-name>instead ofneeds.<job-id>.outputs.<output-name> - Use
@v1version tag instead of@mainbranch
If you currently have the FEISHU_WEBHOOK_URL secret configured in multiple repositories, you can migrate to organization-level secrets for easier management.
Step-by-step migration:
- Create the organization-level secret (see Option 1 above)
- Configure access settings to select which repositories can use the secret
- Verify that at least one repository's workflow runs successfully
- Optional cleanup: Remove the
FEISHU_WEBHOOK_URLsecret from individual repositories
Migration verification checklist:
- Organization-level secret
FEISHU_WEBHOOK_URLhas been created - Access settings are configured for the correct repositories
- At least one workflow using the organization secret runs successfully
- Notification is received in Feishu
Rollback plan:
If you encounter any issues, you can easily rollback:
- Re-create the
FEISHU_WEBHOOK_URLsecret in individual repositories - No changes to workflow files are needed
- Node.js 20 or higher
- TypeScript 5+
# Install dependencies
npm install
# Run locally with tsx
FEISHU_WEBHOOK_URL="your_webhook_url" FEISHU_MESSAGE="Test message" npx tsx src/feishu.tshaginotifier/
├── .github/
│ └── workflows/
│ └── test-notify.yml # Manual test workflow
├── src/
│ ├── feishu.ts # Feishu Webhook implementation
│ ├── types.ts # TypeScript type definitions
│ └── index.ts # Main module exports
├── action.yml # Composite action definition
├── package.json
├── tsconfig.json
└── README.md
You can test the notification action directly from GitHub:
- Go to Actions tab in the haginotifier repository
- Select "Test Notification" workflow
- Click "Run workflow"
- Fill in the parameters:
- message: Your test message content
- msg_type: Choose "text", "post", or "interactive"
- title: (Optional) Title for post/interactive messages
- Click "Run workflow"
The test will send a notification and display the result in the workflow summary.
The codebase is designed to be easily extended with additional notification providers. To add a new provider (e.g., DingTalk, WeCom):
- Create a new module (e.g.,
src/dingtalk.ts) - Implement a similar
sendNotificationfunction - Add provider-specific types to
src/types.ts - Export from
src/index.ts - Update
action.ymlto accept aproviderinput parameter
MIT
Contributions are welcome! Please feel free to submit a Pull Request.
Q: Can I use organization-level secrets with personal repositories?
A: No, organization-level secrets are only available for GitHub organizations. If you're using a personal account, use the per-repository configuration option (Option 2).
Q: Do I need to modify my workflow files when migrating to organization-level secrets?
A: No changes are needed. The workflow configuration remains exactly the same. You just need to configure the secret at the organization level instead of in individual repositories.
Q: What happens if a repository doesn't have access to the organization-level secret?
A: The workflow will fail with an error indicating that the secret is not available. Make sure to configure the access settings when creating the organization-level secret.
Q: Can I mix organization-level and per-repository secrets?
A: Yes, you can use both approaches simultaneously. Some repositories can use the organization-level secret while others manage their own. This is useful during migration.
Q: How do I update the webhook URL for all repositories?
A: With organization-level secrets, simply update the secret value in the organization settings. All repositories with access will automatically use the new value.
Q: What's the difference between the old reusable workflow and the new action?
A: The new action is faster (no runtime TypeScript compilation), uses standard GitHub Actions versioning (@v1), and follows ecosystem best practices. The old workflow syntax is deprecated and will be removed in a future release.
Symptom: Workflow fails with error about FEISHU_WEBHOOK_URL not being found.
Solutions:
- Verify the secret exists at the organization or repository level
- For organization secrets: Check access settings to ensure the repository has access
- Check that the secret name is spelled correctly (case-sensitive)
Symptom: Workflow runs but notification is not received, or webhook returns authentication error.
Solutions:
- Verify the webhook URL is correct and complete
- Check that the custom bot in Feishu is still enabled
- Ensure the webhook hasn't been regenerated or changed in Feishu
Symptom: Error indicating the repository cannot access the organization-level secret.
Solutions:
- Contact your organization administrator to grant access
- Check the secret's access settings in organization settings
- Verify the repository is part of the same organization
Symptom: Notification is received but formatting is incorrect.
Solutions:
- Verify
msg_typeparameter is set correctly (text,post, orinteractive) - Ensure
titleis provided when usingpostorinteractivemessage types - Check that message content follows Feishu's message format requirements