簡體   English   中英

github 操作共享工作區(yml 配置)

[英]github actions share workspace (yml config)

如果我可以運行如下所示的工作流程,那就太酷了 - 也許我只是在 GitHub 操作中缺少一個簡單的配置,但我不知道如何在作業之間共享工作區,同時使用job.needs指定哪個當其他人成功完成時,作業可以運行。

name: Node CI

on: [push]
env:
  CI: true

jobs:
  install:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [12.x]

    steps:
    - uses: actions/checkout@v1
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}
    - name: install node_modules
      run: yarn install

  lint:
    runs-on: ubuntu-latest
    needs: [install]
    steps:
      - name: eslint
        run: yarn lint

  build:
    needs: [install]
    runs-on: ubuntu-latest
    steps:
      - name: yarn build
        run: yarn build

  test:
    needs: [install, build]
    runs-on: ubuntu-latest
    steps:
      - name: jest
        run: yarn test --coverage

我已閱讀Github 操作在作業之間共享工作區/工件? 但我寧願不必上傳node_modules並為每一步下載。

據我所知,操作工作區僅在同一作業的步驟之間共享。 您不能在作業之間共享文件系統。

在作業之間上傳/下載工件是一種解決方案。 您還可以嘗試新的actions/cache操作來緩存node_modules目錄並在后續作業中恢復它。

- uses: actions/cache@v1
  with:
    path: node_modules
    key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
    restore-keys: |
      ${{ runner.os }}-node-

請注意,當前有一些相當嚴格的限制,因此如果您有一個非常大的node_modules目錄,它可能無法正常工作。

單個緩存限制為 400MB,存儲庫最多可以有 2GB 緩存。 達到 2GB 限制后,將根據上次訪問緩存的時間逐出舊緩存。 上周未訪問的緩存也將被驅逐。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM