GitHub Actions:工作流失败通知

28

我们有一个定时的github action,有时会失败。如果它失败了,我该如何收到电子邮件通知?目前,只有工作流程创建者在它失败时会收到电子邮件通知。

my settings


1
我认为目前不可能实现。目前唯一的方法是编写另一个步骤,在构建失败时发送通知。 - Madhu Bhat
那应该可以。我该怎么做呢? - Sam Shleifer
3
请查看此处链接:https://github.com/technote-space/workflow-conclusion-action。 - Uwe Daub
看起来上面的链接只是用于Slack通知。 - undefined
2个回答


6

你可以在你的动作中尝试这个

- name: Send mail
  if: failure()
  uses: dawidd6/action-send-mail@v2
  with:
    # mail server settings
    server_address: smtp.gmail.com
    server_port: 465
    # user credentials
    username: ${{ secrets.EMAIL_USERNAME }}
    password: ${{ secrets.EMAIL_PASSWORD }}
    # email subject
    subject: ${{ github.job }} job of ${{ github.repository }} has ${{ job.status }}
    # email body as text
    body: ${{ github.job }} job in worflow ${{ github.workflow }} of ${{ github.repository }} has ${{ job.status }}
    # comma-separated string, send email to
    to: abc@gmail.com,xyz@gmail.com
    # from email name
    from: XYZ

1
if: always() 这看起来会在每次执行操作时运行,而不仅仅是在失败时运行,这不是 OP 请求的。 - mgalgs

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接