-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Add reusable get-changed-files action and refactor existing actions #26355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add reusable get-changed-files action and refactor existing actions #26355
Conversation
- Create new .github/actions/infrastructure/get-changed-files composite action - Supports both pull_request and push events - Optional filtering by file pattern (e.g., '*.md', '.github/') - Full pagination support (fetches all changed files, not just first 100) - Returns JSON array of file paths for easy consumption - Refactor markdownlinks action to use get-changed-files - Reduced from 108 lines to 77 lines (29% reduction) - Eliminated 31 lines of duplicate file retrieval code - Uses secure environment variable instead of direct string interpolation - Refactor path-filters action to use get-changed-files - Reduced from 130 lines to 123 lines - Eliminated 15+ lines of duplicate pagination logic - Fixed JSON security issue: now uses fromJSON() instead of unsafe JSON.parse() - Added detailed logging for filter analysis - Proper escaping prevents potential code injection from filenames Benefits: - Eliminates ~60 lines of duplicate code across actions - Centralizes file retrieval logic in one place - Improves security with proper JSON handling - Ensures consistent behavior across all actions using changed files - Full pagination ensures no files are missed in large PRs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new reusable composite action get-changed-files to centralize the logic for fetching changed files in PRs and push events, and refactors existing actions to use it. This eliminates code duplication, improves security by using environment variables instead of direct string interpolation, and adds pagination support to handle PRs with more than 100 changed files.
Key changes:
- Created a new
get-changed-filesaction with pagination support, filtering capabilities, and security improvements - Refactored
path-filtersaction to use the newget-changed-filesaction and pass data via environment variables - Updated
markdownlinksaction to use the newget-changed-filesaction for consistency
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
.github/actions/infrastructure/get-changed-files/action.yml |
New reusable action that fetches changed files with pagination support, filtering, and hash verification |
.github/actions/infrastructure/get-changed-files/README.md |
Documentation for the new action including usage examples, inputs, outputs, and limitations |
.github/actions/infrastructure/path-filters/action.yml |
Refactored to use get-changed-files action and receive data via environment variables for security; added detailed logging and removed redundant PowerShell output step |
.github/actions/infrastructure/markdownlinks/action.yml |
Updated to use get-changed-files action with filtering instead of inline GitHub API calls |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
TravisEz13
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…able-get-changed-files-action
…s://github.com/travisez13/powershell into refactor/add-reusable-get-changed-files-action
|
📣 Hey @@TravisEz13, how did we do? We would love to hear your feedback with the link below! 🗣️ 🔗 https://aka.ms/PSRepoFeedback |
…owerShell#26355) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…owerShell#26355) Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Summary
This PR creates a new reusable composite action for retrieving changed files and refactors two existing actions to use it, eliminating duplicate code and improving security.
Changes
1. New Get-Changed-Files Action
2. Refactored Markdownlinks Action
3. Refactored Path-Filters Action
Benefits
Code Reuse: Eliminates ~60 lines of duplicate code across actions
Maintainability: Centralizes file retrieval logic in one place - future changes only need to be made once
Security: Fixes JSON injection vulnerability in path-filters
Consistency: All actions using changed files will behave identically
Completeness: Full pagination ensures no files are missed in large PRs
Clarity: Better logging and documentation
Testing
Related
This is part of splitting up PR #26350 into smaller, more manageable chunks. This PR contains the foundation (reusable action) and refactoring work, while the merge conflict checker will come in a separate PR.