gpt4 book ai didi

github - 在 GitHub Actions 中保存作业失败时的缓存

转载 作者:行者123 更新时间:2023-12-04 11:24:59 32 4
gpt4 key购买 nike

我正在使用 GitHub cache操作,但我注意到如果作业失败,将创建无缓存。来自 docs :

If the job completes successfully, the action creates a new cache with the contents of the path directory.



我的工作流程 YAML 文件的精简版:
name: Build

on: [push]

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v1

- name: Setup Node.js
uses: actions/setup-node@master
with:
node-version: '10.x'

- name: Get yarn cache path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- name: Restore yarn cache
uses: actions/cache@v1
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-

- name: Install yarn dependencies
run: yarn install

- name: Build
run: yarn build

我注意到如果我的 Build步骤失败 cache post-step 将被不必要地跳过,这会导致已安装的依赖项不会被缓存。这需要后续运行以再次下载依赖项,从而减慢了作业速度。

有没有办法始终缓存依赖项,即使构建步骤失败?

最佳答案

在官方版本的操作中,如果构建失败,则无法缓存依赖项。见 this line在缓存操作的 list 中:

runs:
using: 'node12'
main: 'dist/restore/index.js'
post: 'dist/save/index.js'
post-if: 'success()'

如果作业成功,它只会运行后步骤。我不知道这样做的最初原因,但是围绕这个想法存在一些问题。在 this issue用户 forked the action更改 post-ifalways() ,这可能就是您所追求的,假设您愿意采取非官方行动。

关于github - 在 GitHub Actions 中保存作业失败时的缓存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60491837/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com