|
1 | | -# graph-git-repo |
| 1 | +# Generate [mermaid](https://github.com/mermaid-js/mermaid) Repo Structure Action |
| 2 | + |
| 3 | +[](https://github.com/PGSch/graph-git-repo/releases) |
| 4 | +[](https://github.com/PGSch/graph-git-repo/blob/main/LICENSE) |
| 5 | +[](https://github.com/sponsors/PGSch) |
| 6 | +[](https://twitter.com/intent/follow?screen_name=pgschdev) |
| 7 | + |
| 8 | +## Overview |
| 9 | + |
| 10 | +**Generate Repo Structure Action** is a GitHub Action designed to automatically generate a visual representation of your repository's structure using the `tree` command. This action allows users to exclude specific files or directories using customizable patterns, and outputs a structured Markdown file (`REPO_STRUCTURE.md`) with the current repository's layout. |
| 11 | + |
| 12 | +## Features |
| 13 | + |
| 14 | +- **Customizable Exclusions**: Specify patterns to exclude files or directories from the generated structure. |
| 15 | +- **Automatic Markdown Output**: Generates a `REPO_STRUCTURE.md` file with the current repository structure. |
| 16 | +- **Easy Integration**: Simply add this action to your workflow to keep your repository structure up-to-date. |
| 17 | + |
| 18 | +## How It Works |
| 19 | + |
| 20 | +1. **Define the Workflow**: Include this action in your GitHub workflow. |
| 21 | +2. **Customize Exclusions**: Specify which files or directories to exclude through the `exclude_patterns` input. |
| 22 | +3. **Generate Structure**: The action runs a script that creates a `REPO_STRUCTURE.md` file, which is committed back to your repository. |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +To use this action in your repository, include it in your GitHub workflow YAML file. Below is an example configuration: |
| 27 | + |
| 28 | +### Example Workflow |
| 29 | + |
| 30 | +```yaml |
| 31 | +name: Generate Repo Structure |
| 32 | + |
| 33 | +on: |
| 34 | + push: |
| 35 | + branches: |
| 36 | + - main |
| 37 | + workflow_dispatch: |
| 38 | + inputs: |
| 39 | + exclude_patterns: |
| 40 | + description: 'Patterns to exclude (e.g., ".git|*.log|node_modules")' |
| 41 | + required: false |
| 42 | + default: '.git|.DS_Store|.idea|*.log|*.tmp|__pycache__' |
| 43 | + |
| 44 | +jobs: |
| 45 | + generate-structure: |
| 46 | + runs-on: ubuntu-latest |
| 47 | + |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@v3 |
| 50 | + |
| 51 | + - name: Generate Repo Structure |
| 52 | + uses: your-username/generate-repo-structure-action@v1.0.0 |
| 53 | + with: |
| 54 | + exclude_patterns: '${{ github.event.inputs.exclude_patterns }}' |
| 55 | + |
| 56 | + - name: Download Repo Structure |
| 57 | + uses: actions/download-artifact@v3 |
| 58 | + with: |
| 59 | + name: repo-structure |
| 60 | + path: . |
| 61 | +``` |
| 62 | +
|
| 63 | +### Inputs |
| 64 | +
|
| 65 | +| Input Name | Required | Description | |
| 66 | +|--------------------|----------|----------------------------------------------------------------------------------------------------------| |
| 67 | +| `exclude_patterns` | `false` | Patterns to exclude from the tree structure (e.g., ".git|*.log|node_modules"). Default is provided. | |
| 68 | + |
| 69 | +### Outputs |
| 70 | + |
| 71 | +The action generates a `REPO_STRUCTURE.md` file that contains a Markdown-based representation of the repository's structure, excluding specified files and directories. |
| 72 | + |
| 73 | +### Required Permissions |
| 74 | + |
| 75 | +This action requires the following permissions to function properly: |
| 76 | + |
| 77 | +- **Contents**: `write` (to commit the generated structure back to the repository) |
| 78 | + |
| 79 | +## Advanced Configuration |
| 80 | + |
| 81 | +### Customizing Exclusions |
| 82 | + |
| 83 | +You can specify patterns to exclude directly in your workflow file: |
| 84 | + |
| 85 | +```yaml |
| 86 | +with: |
| 87 | + exclude_patterns: '.git|node_modules|*.log|*.env' |
| 88 | +``` |
| 89 | + |
| 90 | +### Triggering the Action |
| 91 | + |
| 92 | +The action will be triggered based on your workflow settings, either automatically on a push or manually through the GitHub UI. |
| 93 | + |
| 94 | +## Contributing |
| 95 | + |
| 96 | +We welcome contributions to improve **Generate Repo Structure Action**! Please open an issue or submit a pull request for any features or bug fixes you’d like to see. |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. |
0 commit comments