|
| 1 | +name: Path Filters |
| 2 | +description: 'Path Filters' |
| 3 | +inputs: |
| 4 | + GITHUB_TOKEN: |
| 5 | + description: 'GitHub token' |
| 6 | + required: true |
| 7 | +outputs: |
| 8 | + source: |
| 9 | + description: 'Source code changes (composite of all changes)' |
| 10 | + value: ${{ steps.filter.outputs.source }} |
| 11 | + githubChanged: |
| 12 | + description: 'GitHub workflow changes' |
| 13 | + value: ${{ steps.filter.outputs.githubChanged }} |
| 14 | + toolsChanged: |
| 15 | + description: 'Tools changes' |
| 16 | + value: ${{ steps.filter.outputs.toolsChanged }} |
| 17 | + propsChanged: |
| 18 | + description: 'Props changes' |
| 19 | + value: ${{ steps.filter.outputs.propsChanged }} |
| 20 | + testsChanged: |
| 21 | + description: 'Tests changes' |
| 22 | + value: ${{ steps.filter.outputs.testsChanged }} |
| 23 | + mainSourceChanged: |
| 24 | + description: 'Main source code changes (any changes in src/)' |
| 25 | + value: ${{ steps.filter.outputs.mainSourceChanged }} |
| 26 | + buildModuleChanged: |
| 27 | + description: 'Build module changes' |
| 28 | + value: ${{ steps.filter.outputs.buildModuleChanged }} |
| 29 | +runs: |
| 30 | + using: composite |
| 31 | + steps: |
| 32 | + - name: Check if GitHubWorkflowChanges is present |
| 33 | + id: filter |
| 34 | + |
| 35 | + with: |
| 36 | + github-token: ${{ inputs.GITHUB_TOKEN }} |
| 37 | + script: | |
| 38 | + // Fetch the list of files changed in the PR |
| 39 | + let files = []; |
| 40 | + let page = 1; |
| 41 | + let fetchedFiles; |
| 42 | + do { |
| 43 | + fetchedFiles = await github.rest.pulls.listFiles({ |
| 44 | + owner: context.repo.owner, |
| 45 | + repo: context.repo.repo, |
| 46 | + pull_number: context.issue.number, |
| 47 | + per_page: 100, |
| 48 | + page: page++ |
| 49 | + }); |
| 50 | + files = files.concat(fetchedFiles.data); |
| 51 | + } while (fetchedFiles.data.length > 0); |
| 52 | +
|
| 53 | + const actionsChanged = files.some(file => file.filename.startsWith('.github/actions')); |
| 54 | + const workflowsChanged = files.some(file => file.filename.startsWith('.github/workflows')); |
| 55 | + const githubChanged = actionsChanged || workflowsChanged; |
| 56 | +
|
| 57 | + const toolsCiPsm1Changed = files.some(file => file.filename.startsWith('tools/ci.psm1')); |
| 58 | + const toolsBuildCommonChanged = files.some(file => file.filename.startsWith('tools/buildCommon/')); |
| 59 | + const toolsChanged = toolsCiPsm1Changed || toolsBuildCommonChanged; |
| 60 | +
|
| 61 | + const propsChanged = files.some(file => file.filename.endsWith('.props')); |
| 62 | +
|
| 63 | + const testsChanged = files.some(file => file.filename.startsWith('test/powershell/') || file.filename.startsWith('test/tools/') || file.filename.startsWith('test/xUnit/')); |
| 64 | +
|
| 65 | + const mainSourceChanged = files.some(file => file.filename.startsWith('src/')); |
| 66 | +
|
| 67 | + const buildModuleChanged = files.some(file => file.filename.startsWith('build.psm1')); |
| 68 | +
|
| 69 | + const source = mainSourceChanged || toolsChanged || githubChanged || propsChanged || testsChanged; |
| 70 | +
|
| 71 | + core.setOutput('toolsChanged', toolsChanged); |
| 72 | + core.setOutput('githubChanged', githubChanged); |
| 73 | + core.setOutput('propsChanged', propsChanged); |
| 74 | + core.setOutput('testsChanged', testsChanged); |
| 75 | + core.setOutput('mainSourceChanged', mainSourceChanged); |
| 76 | + core.setOutput('buildModuleChanged', buildModuleChanged); |
| 77 | + core.setOutput('source', source); |
| 78 | +
|
| 79 | + - name: Capture outputs |
| 80 | + run: | |
| 81 | + Write-Verbose -Verbose "source: ${{ steps.filter.outputs.source }}" |
| 82 | + Write-Verbose -Verbose "github: ${{ steps.filter.outputs.githubChanged }}" |
| 83 | + Write-Verbose -Verbose "tools: ${{ steps.filter.outputs.toolsChanged }}" |
| 84 | + Write-Verbose -Verbose "props: ${{ steps.filter.outputs.propsChanged }}" |
| 85 | + Write-Verbose -Verbose "tests: ${{ steps.filter.outputs.testsChanged }}" |
| 86 | + Write-Verbose -Verbose "mainSource: ${{ steps.filter.outputs.mainSourceChanged }}" |
| 87 | + Write-Verbose -Verbose "buildModule: ${{ steps.filter.outputs.buildModuleChanged }}" |
| 88 | + shell: pwsh |
0 commit comments