[release/v7.5] Add reusable get-changed-files action and refactor existing actions#26811
Conversation
…owerShell#26355) Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Pull request overview
This PR backports the introduction of a reusable composite GitHub Action to retrieve changed files and refactors existing infrastructure actions to consume it, reducing duplication and improving safety when passing JSON between steps.
Changes:
- Add a reusable
.github/actions/infrastructure/get-changed-filescomposite action (with README) to return changed files as JSON for PR and push events. - Refactor
markdownlinksto useget-changed-fileswith a*.mdfilter and pass JSON via environment variables. - Refactor
path-filtersto useget-changed-filesfor PRs and extend its change-detection logging/criteria.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| .github/actions/infrastructure/path-filters/action.yml | Switches PR file enumeration to get-changed-files and expands/clarifies filter logic and logging. |
| .github/actions/infrastructure/markdownlinks/action.yml | Replaces custom changed-file discovery with get-changed-files and uses env var JSON passing. |
| .github/actions/infrastructure/get-changed-files/action.yml | New composite action that fetches changed files for PR/push and optionally filters by simple pattern. |
| .github/actions/infrastructure/get-changed-files/README.md | Documentation and usage examples for the new reusable action. |
| core.setOutput('buildModuleChanged', buildModuleChanged); | ||
| core.setOutput('globalConfigChanged', globalConfigChanged); | ||
| core.setOutput('packagingChanged', packagingChanged); |
There was a problem hiding this comment.
This step sets globalConfigChanged, but the composite action does not declare an action-level output for it in the outputs: block. Either add an output mapping (so callers can read it) or remove this step output if it isn’t intended to be consumed.
| - name: Get changed files | ||
| id: get-files | ||
| if: github.event_name == 'pull_request' | ||
| uses: "./.github/actions/infrastructure/get-changed-files" |
There was a problem hiding this comment.
get-changed-files currently excludes deleted files (only added/modified/renamed). Using it for path-based change detection means deletions of workflow/tools/source files will no longer flip these flags, potentially skipping required CI. Consider adding an input to include deleted files (or return statuses) and use that mode here, so deletions are treated as changes.
| uses: "./.github/actions/infrastructure/get-changed-files" | |
| uses: "./.github/actions/infrastructure/get-changed-files" | |
| with: | |
| include_deleted: true |
| steps: | ||
| - name: Get changed files | ||
| id: get-files | ||
| uses: actions/github-script@v7 |
There was a problem hiding this comment.
Pin actions/github-script to a specific patch version (as done elsewhere in this repo, e.g. actions/[email protected]) to reduce supply-chain risk and keep builds reproducible.
| uses: actions/github-script@v7 | |
| uses: actions/github-script@v7.0.1 |
| - Optional filtering by file pattern | ||
| - Returns files as JSON array for easy consumption | ||
| - Filters out deleted files (only returns added, modified, or renamed files) | ||
| - Handles up to 100 changed files per request |
There was a problem hiding this comment.
The README feature list says the action "Handles up to 100 changed files per request", but the Pagination section later states there is "No file limit" for PRs. Please update the features bullet to match the current pagination behavior (and clarify if push events still have API limits).
| - Handles up to 100 changed files per request | |
| - Supports pagination for pull requests (no file limit) and respects GitHub API limits for push events (up to 100 files per request) |
| core.setOutput('testsChanged', testsChanged); | ||
| core.setOutput('mainSourceChanged', mainSourceChanged); | ||
| core.setOutput('buildModuleChanged', buildModuleChanged); | ||
| core.setOutput('globalConfigChanged', globalConfigChanged); | ||
| core.setOutput('packagingChanged', packagingChanged); | ||
| core.setOutput('source', source); |
There was a problem hiding this comment.
packagingChanged is used by callers to gate packaging jobs, but in the non-PR branch earlier in this script the action sets several outputs to true and does not set packagingChanged. Ensure the non-PR path sets packagingChanged explicitly (likely true) so push/workflow_dispatch runs don’t accidentally skip packaging.
Backport of #26355 to release/v7.5
Triggered by @daxian-dbw on behalf of @TravisEz13
Original CL Label: CL-Tools
/cc @PowerShell/powershell-maintainers
Impact
REQUIRED: Choose either Tooling Impact or Customer Impact (or both). At least one checkbox must be selected.
Tooling Impact
Creates reusable get-changed-files composite action and refactors existing actions to use it
Customer Impact
Regression
REQUIRED: Check exactly one box.
This is not a regression.
Testing
Validated YAML syntax. Actions maintain backward compatibility. Successfully tested in 7.4 and 7.6 releases.
Risk
REQUIRED: Check exactly one box.
Refactors GitHub Actions to use a shared reusable action. Reduces code duplication and fixes a JSON security issue. Successfully backported to 7.4 and 7.6 branches.
Merge Conflicts
Minor conflicts in path-filters/action.yml resolved - context differences in file filtering logic