A GitHub Action that flattens a directory structure containing Markdown files while preserving and updating internal links between documents.
This action:
- Takes a directory containing Markdown files in a nested folder structure
- Moves all files to the root of that directory
- Renames files to avoid naming conflicts (adding folder path in parentheses when needed)
- Updates all internal links between documents to maintain proper references
This is particularly useful for documentation generation workflows where you want a flat structure for publishing or deployment.
To use this action in your project, create a workflow in your GitHub repository similar to this example (customize as needed):
name: Generate and Flatten Documentation
on:
push:
branches: [main, master]
jobs:
flatten_docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# Generate documentation (example using PHP docs generator)
- name: Generate documentation
uses: impresscms-dev/[email protected]
with:
class_root_namespace: YourNamespace\
included_classes: YourNamespace\**
output_path: ./docs/
# Flatten the documentation structure
- name: Flatten documentation structure
uses: impresscms-dev/flattern-markdown-folder-structure-action@v2
with:
path: ./docs/
# Optional: Upload the flattened docs as an artifact
- name: Upload documentation
uses: actions/upload-artifact@v4
with:
name: documentation
path: ./docs/This action supports the following arguments (used with the with keyword):
| Argument | Required | Default value | Description |
|---|---|---|---|
| path | Yes | - | Path to the folder containing Markdown files that should be flattened |
When flattening the directory structure, the action:
- Moves all files to the root directory
- If filename conflicts occur, the action renames files by adding the original folder path in parentheses
- Example:
subfolder/document.mdbecomesdocument (subfolder).md
- Example:
- Updates all internal Markdown links to maintain proper references between documents
docs/
├── README.md
├── getting-started.md
├── api/
│ ├── endpoints.md
│ └── authentication.md
└── guides/
├── installation.md
└── configuration.md
docs/
├── README.md
├── getting-started.md
├── endpoints (api).md
├── authentication (api).md
├── installation (guides).md
└── configuration (guides).md
If you want to add functionality or fix bugs, you can fork the repository, make your changes, and create a pull request. If you're not sure how this works, check out GitHub's fork a repo and creating a pull request guides.
If you find a bug or have questions, please use the issues tab to report them.