【问题标题】:How to skip a configuration of a matrix with GitHub actions?如何使用 GitHub 操作跳过矩阵配置?
【发布时间】:2021-10-29 19:37:56
【问题描述】:

我在 GitHub 操作上有以下工作。我想跳过 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

【问题讨论】:

    标签: workflow github-actions jobs


    【解决方案1】:

    您可以使用exclude

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

    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
    

    【讨论】:

      猜你喜欢
      • 2022-11-25
      • 2021-03-10
      • 2013-09-15
      • 2021-05-07
      • 2020-06-08
      • 2022-01-28
      • 1970-01-01
      • 2021-04-09
      • 1970-01-01
      相关资源
      最近更新 更多