【发布时间】:2020-06-14 22:12:57
【问题描述】:
我正在使用 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 后步骤将被不必要地跳过,这会导致安装的依赖项不会被缓存。这需要后续运行以再次下载依赖项,从而减慢工作速度。
有没有办法始终缓存依赖项,即使构建步骤失败?
【问题讨论】:
标签: github continuous-integration continuous-deployment github-actions