我们确实遇到了一个GitHub操作作业的问题,尽管所有“需要”的作业都成功地运行了,但是这个作业总是被跳过。这就是工作:
deploy-api:
needs: [build-test-api, terraform-apply, set-deployment-env]
uses: ./.github/workflows/workflow-api-deploy.yml为了验证所有需要都通过了,我添加了另一个任务进行调试,并打印了所需作业的结果。
debug-deploy-api:
runs-on: ubuntu-latest
needs: [build-test-api, terraform-apply, set-deployment-env]
if: always() # Had to add this, otherwise it would be skipped just as "deploy-api".
steps:
- run: |
echo "Result of build-test-api: ${{ needs.build-test-api.result }}"
echo "Result of terraform-apply: ${{ needs.terraform-apply.result }}"
echo "Result of set-deployment-env: ${{ needs.set-deployment-env.result }}"输出是
Result of build-test-api: success
Result of terraform-apply: success
Result of set-deployment-env: success我不明白为什么跳过deploy-api。
在这一变化之后,工作开始被跳过。
此行为在向build-test-api添加依赖项后开始。
使用这个版本的build-test-api,部署作业确实运行得很好:
build-test-api:
uses: # reusable WF from internal repo
needs: set-deployment-env在把它变成
build-test-api:
uses: # reusable WF from internal repo
needs: [set-deployment-env, auto-versioning]
if: |
always() &&
(needs.set-deployment-env.result == 'success') &&
(needs.auto-versioning.result == 'success' || needs.auto-versioning.result == 'skipped')deploy-api一直被跳过。但是,尽管进行了更改,build-test-api仍然运行良好,甚至将创建的工件附加到工作流运行中。
激活运行程序和步骤调试日志没有显示任何关于为什么仍然跳过作业的洞察。有什么想法吗?
发布于 2022-11-22 08:17:23
与此同时,我确实联系了GitHub高级支持部门,他们提供了一个解决方案:
deploy-api:
if: success('build-test-api') # This line is required, if any of the previous job did not end with status 'success'.
needs: build-test-api
uses: ./.github/workflows/48-reusable-workflow-2.yml我想我也知道为什么:文档说:
您可以使用以下状态检查函数作为
if条件项中的表达式。除非包含这些函数之一,否则将应用success()的默认状态检查。
success()如下:
当前面的步骤都没有失败或被取消时,返回
true。
我认为唯一的问题应该是:
当前面的步骤都没有失败、取消或跳过时,返回
true。
https://stackoverflow.com/questions/74386773
复制相似问题