question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Use strategy matrix to check if paths was changed

See original GitHub issue

For example, I have targets array in my matrix. Then I use this action to detect changed changed with filters named exactly the same as targets:

jobs:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest]
        target: [first, second]
    steps:
    - name: Detect changes
      uses: dorny/paths-filter@v2.2.0
      id: changes
      with:
        filters: |
          first:
            - /some/path/**
          second:
            - some/another/path/**

Is there a way to check if matrix target was filtered? Something like the following:

    - name: My Action
      if: contains(steps.changes.outputs, matrix.target)
      run: echo "test"

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
MartinNowakcommented, Aug 3, 2020

Doesn’t this run your detect changes for each matrix entry? If that’s intended, you could just make the matching path a parameter of the matrix. Sth. like this (untested):

jobs:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest]
        target:
          - name: first
            paths: /some/path/**
          - name: second
            paths: some/another/path/**
    steps:
    - name: Detect changes
      uses: dorny/paths-filter@v2.2.0
      id: changes
      with:
        filters: |
          matched:
            - ${matrix.target.paths}
0reactions
Shaturcommented, Aug 3, 2020

I overlooked, it works, thank you a lot!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using a matrix for your jobs - GitHub Docs
A matrix strategy lets you use variables in a single job definition to automatically create multiple job runs that are based on the...
Read more >
Github Actions: How use strategy/matrix with script
It detects changed files and runs build job for changed directories. If directory name starts with OS name, it uses that name as...
Read more >
How to Use the GitHub Actions Matrix Strategy in Deployments
Learn how to use the GitHub Actions Matrix deployment strategy and take your actions to the next level in this ATA Learning tutorial....
Read more >
How-to Github Actions: Build Matrix - Nicola Corti
How to use Build Matrix to test your project against different version of a language, a library or an operating system.
Read more >
Generating Dynamic GitHub Actions Workflows with the Job ...
Checking out the documentation, we found out that you can use a previous job's output as input for a job strategy, including the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found