From 76cc1966678a2b1413229e907028625a714fbec3 Mon Sep 17 00:00:00 2001 From: Phantom Date: Fri, 9 Jan 2026 11:35:17 +0800 Subject: [PATCH] ci(workflows): add Feishu notification for workflow failures (#12375) * ci(workflows): add feishu notification for failed sync jobs Add Feishu webhook notification when sync-to-gitcode workflow fails or is cancelled. The notification includes tag name, status and run URL for quick debugging. * ci(workflow): add feishu notification for failed or cancelled jobs --- .github/workflows/auto-i18n.yml | 27 ++++++++++++++++++++++++++ .github/workflows/sync-to-gitcode.yml | 28 +++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) diff --git a/.github/workflows/auto-i18n.yml b/.github/workflows/auto-i18n.yml index d4bf43dc26..541f174d33 100644 --- a/.github/workflows/auto-i18n.yml +++ b/.github/workflows/auto-i18n.yml @@ -90,3 +90,30 @@ jobs: - name: 📢 Notify if no changes if: steps.git_status.outputs.has_changes != 'true' run: echo "Bot script ran, but no changes were detected. No PR created." + + - name: Send failure notification to Feishu + if: always() && (failure() || cancelled()) + shell: bash + env: + FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }} + FEISHU_WEBHOOK_SECRET: ${{ secrets.FEISHU_WEBHOOK_SECRET }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + JOB_STATUS: ${{ job.status }} + run: | + # Determine status and color + if [ "$JOB_STATUS" = "cancelled" ]; then + STATUS_TEXT="已取消" + COLOR="orange" + else + STATUS_TEXT="失败" + COLOR="red" + fi + + # Build description using printf + DESCRIPTION=$(printf "**状态:** %s\n\n**工作流:** [查看详情](%s)" "$STATUS_TEXT" "$RUN_URL") + + # Send notification + pnpm tsx scripts/feishu-notify.ts send \ + -t "自动国际化${STATUS_TEXT}" \ + -d "$DESCRIPTION" \ + -c "${COLOR}" diff --git a/.github/workflows/sync-to-gitcode.yml b/.github/workflows/sync-to-gitcode.yml index ae6006ee76..bfc544d405 100644 --- a/.github/workflows/sync-to-gitcode.yml +++ b/.github/workflows/sync-to-gitcode.yml @@ -300,3 +300,31 @@ jobs: run: | rm -f /tmp/release_payload.json /tmp/upload_headers.txt release_body.txt rm -rf release-assets/ + + - name: Send failure notification to Feishu + if: always() && (failure() || cancelled()) + shell: bash + env: + FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL }} + FEISHU_WEBHOOK_SECRET: ${{ secrets.FEISHU_WEBHOOK_SECRET }} + TAG_NAME: ${{ steps.get-tag.outputs.tag }} + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + JOB_STATUS: ${{ job.status }} + run: | + # Determine status and color + if [ "$JOB_STATUS" = "cancelled" ]; then + STATUS_TEXT="已取消" + COLOR="orange" + else + STATUS_TEXT="失败" + COLOR="red" + fi + + # Build description using printf + DESCRIPTION=$(printf "**标签:** %s\n\n**状态:** %s\n\n**工作流:** [查看详情](%s)" "$TAG_NAME" "$STATUS_TEXT" "$RUN_URL") + + # Send notification + pnpm tsx scripts/feishu-notify.ts send \ + -t "GitCode 同步${STATUS_TEXT}" \ + -d "$DESCRIPTION" \ + -c "${COLOR}"