Skip to content

Commit d6c72a5

Browse files
committed
feat: action.yml
1 parent 2527d36 commit d6c72a5

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

action.yml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "Graph Git Repo"
2+
description: "Generates a repository structure and Mermaid diagram using ChatGPT, uploads them as artifacts, and optionally creates a PR."
3+
author: "github-actions[bot]"
4+
inputs:
5+
exclude_patterns:
6+
description: 'Patterns to exclude (e.g., ".git|*.log|node_modules")'
7+
required: false
8+
default: '.git|.DS_Store|.idea|*.log|*.tmp|__pycache__'
9+
depth:
10+
description: 'Tree depth to consider'
11+
required: false
12+
default: '2'
13+
create_pr:
14+
description: 'Whether to create a pull request with the generated files'
15+
required: false
16+
default: 'false'
17+
type: boolean
18+
19+
runs:
20+
using: "composite"
21+
steps:
22+
- name: Checkout target repository code
23+
uses: actions/checkout@v3
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v3
27+
with:
28+
node-version: '18'
29+
30+
- name: Install Tree Command
31+
run: sudo apt-get install -y tree
32+
33+
- name: Generate Repo Structure
34+
run: |
35+
chmod +x ${{ github.action_path }}/base.sh
36+
bash ${{ github.action_path }}/base.sh '${{ inputs.exclude_patterns }}' '${{ inputs.depth }}'
37+
shell: bash
38+
39+
- name: Set up Python
40+
uses: actions/setup-python@v3
41+
with:
42+
python-version: '3.10'
43+
44+
- name: Install Python dependencies
45+
run: pip install openai
46+
47+
- name: Generate Mermaid Diagram using ChatGPT
48+
env:
49+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
50+
run: python ${{ github.action_path }}/tree_to_gpt.py
51+
52+
- name: Upload Generated Files as Artifacts
53+
uses: actions/upload-artifact@v3
54+
with:
55+
name: repo-structure-and-diagram
56+
path: |
57+
REPO_STRUCTURE.md
58+
MERMAID_DIAGRAM.md
59+
60+
- name: Commit Changes (if create_pr is true)
61+
if: inputs.create_pr == 'true'
62+
run: |
63+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
64+
git config --local user.name "github-actions[bot]"
65+
git add REPO_STRUCTURE.md MERMAID_DIAGRAM.md
66+
git commit -m "[bot] Update repository structure and Mermaid diagram"
67+
shell: bash
68+
69+
- name: Create Pull Request (if create_pr is true)
70+
if: inputs.create_pr == 'true'
71+
uses: peter-evans/create-pull-request@v6
72+
with:
73+
author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
74+
title: "Update repository structure and Mermaid diagram"
75+
branch: update-repo-structure-${{ github.run_id }}
76+
labels: "automated-update"
77+
env:
78+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
79+
80+
branding:
81+
icon: "git-merge"
82+
color: "blue"
83+

0 commit comments

Comments
 (0)