feat: add flatten option to copy directory contents without parent folder
#216
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds a new
flattenparameter to automatically copy directory contents without including the parent folder structure in the target destination. This solves the common issue wheresource: "build/*"creates an unwantedbuild/subdirectory on the remote server.Context
Fixes common user pain point where deploying build outputs (e.g.,
build/*,dist/*) creates unnecessary parent folders on the target server. Users previously had to manually calculatestrip_componentsvalues or restructure their deployment process.Problem:
source: "build/*"to copy only contentstarget/build/file.htmlinstead oftarget/file.htmlstrip_componentscalculation is error-prone and non-intuitiveChanges Made
action.yml:
flatteninput parameter (default:false)INPUT_FLATTENenvironment variableentrypoint.sh:
process_flatten()function with intelligent path parsingfolder/*)folder/) correctlystrip_componentswhen flatten is enabledstrip_components(no override if manually set)Documentation (README.md, README.zh-cn.md, README.zh-tw.md):
flattento File Transfer Settings configuration tableUsage Example
Before (Problem):
After (Solution):
How It Works
The
flattenfeature intelligently analyzes source paths and automatically calculates the correctstrip_componentsvalue:build/*truebuild/parenttest-flatten/build/*truesrc/components/ui/*truebuild/*,dist/*truebuild/*falseTesting
✅ All tests passed successfully!
Unit Tests :
build/*) - correctly sets strip=1test-flatten/build/*) - correctly sets strip=2src/components/build/*) - correctly sets strip=3build/) - correctly handlesbuild/*,dist/*) - uses max depthDocumentation
Complete documentation provided: