Search code examples
github-actionscicd

Output based on conditional github action matrix build


I am running a below job in github actions (sample).

jobs:
  gradle:
    strategy:
      matrix:
        jdk: [11, 14]
    runs-on: [linux]

  steps:
    - name: Checkout Repo
      uses: actions/checkout@v2
    ...
    - name: gradle Build
      uses: abc_workflow@v1
      with:
        java-version: ${{ matrix.jdk }}

I want to implement a condition, where if build based on jdk version 11 is passing, it should pass the result of overall workflow and if build based on jdk version 11 is failing, it should fail the overall workflow, irrespective of the build result of version jdk 14.

Can someone please help with this situation?


Solution

  • You can tell it to not fail when a specific matrix job fails:

    jobs:
      gradle:
        continue-on-error: ${{ matrix.jdk == 14 }}
        strategy:
          matrix:
            jdk: [11, 14]
    

    See Handling failures in the documentation.