Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to skip a configuration of a matrix with GitHub actions?

I have the following job on GitHub actions. And I would to like to skip the macOS x86 configuration: is there a way to do this?

  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
like image 313
JJB Avatar asked Dec 12 '25 06:12

JJB


1 Answers

You can use 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

In your case it would be:

      matrix:
        os: [ubuntu-latest, macOS, windows-latest]
        java: [15]
        architecture: [x86, x64]
        include:
          - compiler: gcc
            gcc: 8
        exclude:
          - os: macOS
like image 76
Krzysztof Madej Avatar answered Dec 16 '25 22:12

Krzysztof Madej



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!