我们有一个定时的github action,有时会失败。如果它失败了,我该如何收到电子邮件通知?目前,只有工作流程创建者在它失败时会收到电子邮件通知。
我们有一个定时的github action,有时会失败。如果它失败了,我该如何收到电子邮件通知?目前,只有工作流程创建者在它失败时会收到电子邮件通知。
if: ${{ failure() }}
。你可以在你的动作中尝试这个
- 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
if: always()
这看起来会在每次执行操作时运行,而不仅仅是在失败时运行,这不是 OP 请求的。 - mgalgs