You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取被telegram-notifier触发的已完成工作流名称?

解决方法

要获取已完成的工作流名称,直接使用GitHub Actions上下文变量 ${{ github.event.workflow_run.name }} 即可,该变量会返回触发当前telegram-notifier工作流的已完成工作流名称(即workflowA/workflowB/workflowC中的某一个)。

修改后的通知内容

更新通知内容,加入工作流名称字段:

已完成工作流: ${{ github.event.workflow_run.name }}
创建时间: ${{ github.event.workflow_run.created_at }}
触发用户: ${{ github.actor }}
仓库: ${{ github.repository }}
状态: ${{ github.event.workflow_run.status }}
执行结果: 任务已完成,结果为 ${{ github.event.workflow_run.conclusion }}

完整工作流配置示例(含发送步骤)

如果需要参考完整配置,假设你已配置Telegram密钥,可使用如下模板:

name: telegram-notifier
on: 
  workflow_run:
    workflows: [workflowA,workflowB,workflowC]
    types:
      - completed

jobs:
  send-telegram-alert:
    runs-on: ubuntu-latest
    steps:
      - name: 发送Telegram通知
        uses: appleboy/telegram-action@v0.1.1
        with:
          to: ${{ secrets.TELEGRAM_TO }}
          token: ${{ secrets.TELEGRAM_TOKEN }}
          message: |
            已完成工作流: ${{ github.event.workflow_run.name }}
            创建时间: ${{ github.event.workflow_run.created_at }}
            触发用户: ${{ github.actor }}
            仓库: ${{ github.repository }}
            状态: ${{ github.event.workflow_run.status }}
            执行结果: 任务已完成,结果为 ${{ github.event.workflow_run.conclusion }}

内容的提问来源于stack exchange,提问作者Ayadi Mohamed

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.15 06:55:17