因为当没有要提交的更改时 git 会使用非零代码提交退出,这会导致 github 操作失败。为了克服这个问题,我尝试在提交之前检查是否有任何更改,如下所示 -
if git diff-index --quiet HEAD --; then
echo "changes_exist=true" >> $GITHUB_ENV
else
echo "changes_exist=false" >> $GITHUB_ENV
fi
然后 GitHub 在其下方向我展示了这一点 -shell: /bin/bash -e {0}
谷歌搜索似乎没有产生任何结果。知道这意味着什么吗?
跑步者的精确输出 -
Run if git diff-index --quiet HEAD --; then
if git diff-index --quiet HEAD --; then
echo "changes_exist=true" >> $GITHUB_ENV
else
echo "changes_exist=false" >> $GITHUB_ENV
fi
shell: /bin/bash -e {0}
env:
pythonLocation: /opt/hostedtoolcache/Python/3.9.1/x64
LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.1/x64/lib
{0}
被替换为run
工作流程定义中的元素
https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#using-a-specific-shell
如果您使用例如,您还可以更改错误处理
run: echo "Test"
shell: bash {0}
这会导致调用bash echo "Test"
代替bash -e echo "Test"
.
https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)