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
我已阅读 但我不想每一步都上传 node_modules
和下载。
据我所知,操作工作区仅在同一作业的步骤之间共享。您不能在作业之间共享文件系统。
Uploading/downloading 作业之间的工件是一种解决方案。您还可以尝试新的 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
目录,它可能无法工作。
Individual caches are limited to 400MB and a repository can have up to 2GB of caches. Once the 2GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted.
如果我能 运行 一个如下所示的工作流就好了 - 也许我只是缺少 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
我已阅读 node_modules
和下载。
据我所知,操作工作区仅在同一作业的步骤之间共享。您不能在作业之间共享文件系统。
Uploading/downloading 作业之间的工件是一种解决方案。您还可以尝试新的 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
目录,它可能无法工作。
Individual caches are limited to 400MB and a repository can have up to 2GB of caches. Once the 2GB limit is reached, older caches will be evicted based on when the cache was last accessed. Caches that are not accessed within the last week will also be evicted.