我正在使用 GitHub 的 cache 动作,但我注意到如果作业失败,将不会创建缓存。根据 docs :
我注意到如果我的
是否有一种方法可以始终缓存依赖项,即使构建步骤失败?
以下是我的工作流 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
后置步骤将不必要地被跳过,这会导致安装的依赖项不能被缓存。这需要随后的运行再次下载依赖项,减慢了作业的速度。是否有一种方法可以始终缓存依赖项,即使构建步骤失败?