Skip to content

How to conditionally include/exclude items in matrix (eg. based on branch)? #26253

Answered by hpoul
DanTup asked this question in Actions
Discussion options

You must be logged in to vote

I think I have now found a workaround for excluding matrix options based on branch. The idea is to simply add the github.ref variable to the matrix and then exclude it:

    strategy:
      matrix:
        flavor: ['playstoredev', 'samsungapps', 'sideload', 'huawei', 'amazon']
        shouldRelease:
          - ${{ contains(github.ref, 'stable') || startsWith(github.ref, 'refs/heads/v') }}
        isMaster:
          - ${{ contains(github.ref, 'master') }}
        exclude:
          - shouldRelease: false
            flavor: amazon
          - shouldRelease: false
            flavor: huawei
          - shouldRelease: false
            flavor: samsungapps

with this configuration only on al…

Replies: 8 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants