test-reporter icon indicating copy to clipboard operation
test-reporter copied to clipboard

want to filter on changes in `CHANGELOG.md` but also returns true when others `.md` files are changed

Open root-ansh-ct opened this issue 2 years ago • 0 comments

name: validate PR 
on:
  pull_request:
    branches: [ develop ]

jobs:
  lint-static_checks-test-build:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write

    steps:
      - name: check if mandatory files are changed
        uses: dorny/paths-filter@v2
        id: filter
        with:
          filters: |
            md:
              - 'CHANGELOG.md'

      - name: FAIL if mandatory files are not changed
        if: ${{ steps.filter.outputs.md == 'false' }}
        uses: actions/github-script@v3
        with:
          script: |
            core.setFailed('Mandatory markdown files were not changed')

my intent with this code is to fail the action if CHANGELOG.md is not changed for a PR. but I have 3 questions:

  1. For a PR, the action run whenever we push a commit to source branch. So if one particular commit had changelog.md changed, this would mean that all the subsequent commit push will automatically consider the file as changed and this filter will always return true? or is it made against every single commit, like if commit A changed CHANGELOG.md but commit B didn't, then would it fail for commit B?
  2. is this filter even targeting CHANGELOG.md or just md files in general?
  3. if the filter considers the total no. of file changes in the head commit, and not the previous commits, then would it fail, if i changed the CHANGELOG.md , then undo-ed the changes in that file?

root-ansh-ct avatar Mar 17 '22 07:03 root-ansh-ct