如何在 GitHub Actions 中跳过矩阵的配置?

11
我在GitHub actions上有这样一个任务,我想跳过macOS x86的配置:有没有方法可以实现这一点?
  build-and-push-native-libraries:
    name: Build and push native library on ${{ matrix.os }} ${{ matrix.architecture }}
    strategy:
      fail-fast: true
      matrix:
        os: [ubuntu-latest, macOS, windows-latest]
        java: [15]
        architecture: [x86, x64]
        include:
          - compiler: gcc
            gcc: 8
    runs-on: ${{ matrix.os }}
    steps:
      - name: Set up JDK ${{ matrix.java }}
        uses: actions/setup-java@v1
        with:
          java-version: ${{ matrix.java }}
          architecture: ${{ matrix.architecture }}
      - uses: actions/checkout@v2
      - if: startsWith(matrix.os, 'ubuntu') == true
        name: Change the permissions of the build script of external classes
        run: chmod +x ./java/src/main/resources/compileExternalClasses.sh
      - name: Build and push native library
        run: |
          mvn -B clean package -DskipTests=true --file ./native/pom.xml
          git config user.name "${{ github.event.head_commit.committer.name }}"
          git config user.email "${{ github.event.head_commit.committer.email }}"
          git pull origin experimental
          git commit -am "Generated library for ${{ matrix.os }} ${{ matrix.architecture }}" --allow-empty
          git push
1个回答

20

您可以使用exclude选项。

通过使用exclude选项,您可以从构建矩阵中删除特定的配置。使用exclude会删除由构建矩阵定义的作业。作业数量是您提供的数组中包含的操作系统(os)数量的乘积减去任何减法(exclude)。

runs-on: ${{ matrix.os }}
strategy:
  matrix:
    os: [macos-latest, windows-latest, ubuntu-18.04]
    node: [8, 10, 12, 14]
    exclude:
      # excludes node 8 on macOS
      - os: macos-latest
        node: 8

在您的情况下,它将是:

      matrix:
        os: [ubuntu-latest, macOS, windows-latest]
        java: [15]
        architecture: [x86, x64]
        include:
          - compiler: gcc
            gcc: 8
        exclude:
          - os: macOS

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接