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

GitHub Actions发送邮件附件报错EISDIR:恳请帮忙排查原因

GitHub Actions邮件附件EISDIR错误排查方案

问题原因

你遇到的Error: EISDIR: illegal operation on a directory, read错误,是因为dawidd6/action-send-mail@v3仅支持添加文件作为附件,而当前配置里的./cypress-results/*会匹配到下载后的子目录(如screenshots、videos),导致动作试图读取目录引发错误。

解决方法

方法1:递归匹配所有文件

修改邮件步骤的attachments配置,使用递归通配符匹配所有子目录下的文件:

- name: Send email with Cypress artifacts
  uses: dawidd6/action-send-mail@v3
  with:
    server_address: smtp.gmail.com
    server_port: 465
    username: ${{ secrets.EMAIL_USERNAME }}
    password: ${{ secrets.EMAIL_PASSWORD }}
    subject: "Cypress test results for ${{ github.repository }} ${{ github.sha }}"
    from: Test Suite
    body: |
      Hi,
      The Cypress test workflow for ${{ github.repository }} ${{ github.sha }} has completed.
      Please find the Cypress artifacts attached to this email.
      Regards,
      abc
    to: abc@gmail.com
    attachments: |
      ./cypress-results/**/*

**/*会递归遍历cypress-results下的所有文件,确保只传入文件作为附件。

方法2:打包目录为ZIP(推荐)

先将整个artifact目录打包成单个ZIP文件,再添加为附件,既避免目录读取错误,也让收件人更易下载:

- name: Download Cypress artifacts
  uses: actions/download-artifact@v2
  with:
    name: cypress-results
    path: cypress-results

# 添加打包步骤
- name: Package artifacts into ZIP
  run: zip -r cypress-results.zip cypress-results/

- name: Send email with Cypress artifacts
  uses: dawidd6/action-send-mail@v3
  with:
    server_address: smtp.gmail.com
    server_port: 465
    username: ${{ secrets.EMAIL_USERNAME }}
    password: ${{ secrets.EMAIL_PASSWORD }}
    subject: "Cypress test results for ${{ github.repository }} ${{ github.sha }}"
    from: Test Suite
    body: |
      Hi,
      The Cypress test workflow for ${{ github.repository }} ${{ github.sha }} has completed.
      Please find the Cypress artifacts attached to this email.
      Regards,
      abc
    to: abc@gmail.com
    attachments: |
      ./cypress-results.zip

额外优化

Send-Email任务中的actions/checkout@v2步骤可以删除,因为该任务只需要下载artifact,无需检出代码仓库内容,减少不必要的操作。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.26 16:32:46