Github actions如何让某个step自动重试
如果您发现本文排版有问题,可以先点击下面的链接切换至老版进行查看!!!
Github actions如何让某个step自动重试
最近有个github action项目中的某个步骤step需要执行下载文件,但是近期开始出现下载超时的情况,并且还有点频繁。自己除了找服务器的原因以外,还想通过优化github actions来尽量避免下载超时的问题。
在网上搜了下,github actions官方没有这样的功能,但是好在第三方的actions里面有,那就省事多了。
有个叫nick-fields/retry@v3
的,我们可以直接利用它来实现重试功能,参数配置也很简单。
截取里面几个有用的配置
Inputs:
timeout_minutes Required Minutes to wait before attempt times out. Must only specify either minutes or seconds
timeout_seconds Required Seconds to wait before attempt times out. Must only specify either minutes or seconds
max_attempts Required Number of attempts to make before failing the step
用法如下:
name: Run script
uses: nick-fields/retry@v3
with:
timeout_minutes: 10
timeout_seconds: 120
max_attempts: 3
command: npm run some-typically-slow-script
除了能配置Inputs外还能配置Outputs呢
Outputs
total_attempts The final number of attempts made
exit_code The final exit code returned by the command
exit_error The final error returned by the command
- 分类:
- Devops
更新时间:
上一篇:下一篇: