升级actions/upload-artifact@v4.4.0后路径匹配失效求助
问题分析与修正方案
actions/upload-artifact v4版本对路径glob的解析逻辑做了调整(v3基于Node.js glob,v4默认使用Runner的shell解析),你当前的路径写法存在冗余和不规范的问题,导致匹配失效。以下是修正后的配置和原因说明:
修正后的最简配置
直接复用v3的相对路径写法即可,v4完全支持这种简洁的匹配规则:
- name: "Upload Artifacts Plan files" uses: actions/upload-artifact@v4.4.0 if: failure() || success() with: name: terragrunt-plan retention-days: 7 overwrite: true path: | **/*.tfplan **/plan.txt **/.terraform.lock.hcl
若需使用绝对路径的规范写法
如果因为工作目录切换等特殊场景必须用绝对路径,需避免冗余的**/**写法(**已能匹配任意层级子目录):
- name: "Upload Artifacts Plan files" uses: actions/upload-artifact@v4.4.0 if: failure() || success() with: name: terragrunt-plan retention-days: 7 overwrite: true path: | ${{ github.workspace }}/**/*.tfplan ${{ github.workspace }}/**/plan.txt ${{ github.workspace }}/**/.terraform.lock.hcl
原配置失效的核心原因
- 冗余的
**/**写法:**本身就代表任意层级的子目录,叠加**/**属于无效写法,会导致shell解析glob时出现异常。 - 重复的路径规则:你配置中多次重复
.terraform.lock.hcl的匹配路径,属于冗余操作,且可能干扰解析逻辑。 - 绝对路径与相对路径混用:混合使用绝对路径和相对路径时,shell的glob解析可能出现优先级冲突,导致部分路径匹配失效。
验证建议
可以在上传步骤前新增一个文件列表步骤,确认目标文件存在且路径可被正确匹配:
- name: Verify target files exist run: | find ${{ github.workspace }} -name "*.tfplan" find ${{ github.workspace }} -name "plan.txt" find ${{ github.workspace }} -name ".terraform.lock.hcl"
内容的提问来源于stack exchange,提问作者Sankar
相关产品推荐
相关产品推荐

