workflow - 如何使用 GitHub 操作跳过矩阵配置?

标签 workflow github-actions jobs

我在 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

最佳答案

您可以使用 exclude

You can remove a specific configurations defined in the build matrix using the exclude option. Using exclude removes a job defined by the build matrix. The number of jobs is the cross product of the number of operating systems (os) included in the arrays you provide, minus any subtractions (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

关于workflow - 如何使用 GitHub 操作跳过矩阵配置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68994484/

相关文章:

c# - 应用开发流程

aws-cli - GitHub Action -AWS CLI

php - 保存 bean 是否会删除记录与 SuiteCRM 中电子邮件的连接?

c# - 哪种代码模式最适合处理周期性和可变的 Action 流

Django 中的 Javascript 开发工作流程

git - 多开发人员 Git 工作流程,保持干净的历史记录

github-actions - 使用 GitHub 操作自动从特定分支创建新的 PR?

github-actions - GitHub Action Cache with npm install -g(没有 package.json)

Powershell:从 Receive-Job 获取输出

jobs - 这是在sql server中删除多个作业的正确方法