dorny / paths-filter

Conditionally run actions based on files modified by PR, feature branch or pushed commits
MIT License
2.11k stars 238 forks source link

Using filter output in jobs `if` does not make a difference #119

Open ivankovnatsky opened 2 years ago

ivankovnatsky commented 2 years ago

Thanks for your time working on this project!

Goal: Do not run the job if the files under infrastructure/ changed.

While somehow it does not work in jobs if, it does outputs the value in the further commands.

I'm not sure if this is GitHub's issue or the action itself.

I've followed this example here: https://github.com/dorny/paths-filter#conditional-execution

"Execute job in a workflow only if some file in a subfolder is changed"

  filter-check:
    container: alpine/git:v2.32.0
    outputs:
      infra: "${{ steps.filter.outputs.infra }}"
    steps:
      - id: filter
        uses: "dorny/paths-filter@v2"
        with:
          filters: |
            infra:
              - 'infrastructure/**'

  dhall-check:
    container: dhallhaskell/dhall:1.40.2
    needs:
      - filter-check
    if: "${{ needs.filter-check.outputs.infra }} == 'false'"
    steps:
      - name: Checkout repository
        uses: "actions/checkout@v2"
        with:
          fetch-depth: '30'
          token: "${{ secrets.SECRET_TOKEN }}"
      - uses: "dhall-lang/setup-dhall@v4"
      - run: dhall version
      - name: Generate ci.yml
        run: make -C ci generate
      - name: Output show
        run: "echo ${{ needs.filter-check.outputs.infra }}"
      - name: Make sure that ci.yml is synchronized with its Dhall source
        run: git diff --exit-code ci/

image

kpturner commented 2 years ago

Just use

if: needs.filter-check.outputs.infra == 'false'