我的工作流程有问题。我在
.github/workflows
目录下有几个文件。
为了这篇文章的目的,我们假设 2:build.yml
和 cypress.yml
。我想仅在满足 paths
标准时触发工作流程/作业,因此在没有添加/修改 *.test-cy.tsx
文件之前,柏树测试不会运行。
name: CI
on:
push:
paths: ["**/*", "!.github/**/*"]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "package-lock.json"
- run: npm ci
- run: npm run build --if-present
- run: npm run build-storybook --if-present
name: Cypress
on:
push:
paths: ["src/**/*.test-cy.{js,jsx,ts,tsx}"]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20.x]
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "npm"
cache-dependency-path: "package-lock.json"
- run: npm ci
- run: npm run test:cypress --if-present
当我推送提交时,只有第一个运行。我也尝试在具有多个作业的一个工作流程中执行此操作,但找不到
if:
的正确条件。
This 是 github 操作的过滤器模式备忘单。没有
{
和}
的字符。这可能有效:
name: Cypress
on:
push:
paths:
- 'src/**/*.test-cy.tsx?'
- 'src/**/*.test-cy.jsx?'
jobs:
test:
runs-on: ubuntu-latest