Skip to content

Commit 40b79db

Browse files
committed
Add auto-update README structure workflow
1 parent 8774b4b commit 40b79db

2 files changed

Lines changed: 82 additions & 1 deletion

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# .github/workflows/update_readme.yml
2+
name: Update README Project Structure
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
jobs:
9+
update-readme:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
token: ${{ secrets.GITHUB_TOKEN }}
15+
16+
- name: Install tree
17+
run: sudo apt-get install tree
18+
19+
- name: Generate project structure
20+
run: |
21+
# Generate tree structure excluding common ignore patterns
22+
tree -I 'node_modules|.git|.github|__pycache__|*.pyc|.env|.venv|dist|build|.DS_Store' | sed 's/^\./nvim/' > temp_structure.txt
23+
24+
# Create the updated README section
25+
cat > temp_section.md << 'EOF'
26+
### Project Structure
27+
```
28+
EOF
29+
30+
cat temp_structure.txt >> temp_section.md
31+
32+
cat >> temp_section.md << 'EOF'
33+
```
34+
EOF
35+
36+
- name: Update README
37+
run: |
38+
# Check if README exists
39+
if [ ! -f README.md ]; then
40+
echo "README.md not found!"
41+
exit 1
42+
fi
43+
44+
# Replace the project structure section
45+
# This assumes you have markers in your README like:
46+
# <!-- PROJECT_STRUCTURE_START -->
47+
# <!-- PROJECT_STRUCTURE_END -->
48+
49+
awk '
50+
/<!-- PROJECT_STRUCTURE_START -->/ {
51+
print $0
52+
while ((getline line < "temp_section.md") > 0) {
53+
print line
54+
}
55+
skip = 1
56+
next
57+
}
58+
/<!-- PROJECT_STRUCTURE_END -->/ {
59+
skip = 0
60+
print $0
61+
next
62+
}
63+
!skip { print }
64+
' README.md > README_new.md
65+
66+
mv README_new.md README.md
67+
rm temp_structure.txt temp_section.md
68+
69+
- name: Commit changes
70+
run: |
71+
git config --local user.email "action@github.com"
72+
git config --local user.name "GitHub Action"
73+
git add README.md
74+
if git diff --staged --quiet; then
75+
echo "No changes to commit"
76+
else
77+
git commit -m "Auto-update project structure in README"
78+
git push
79+
fi

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@ Inspired by [LazyVim](https://github.com/LazyVim/LazyVim) and [AstroNvim](https:
2424
- [trouble.nvim](https://github.com/folke/trouble.nvim)
2525
- And much more
2626

27-
### Project Structure
27+
<!-- PROJECT_STRUCTURE_START -->
2828

2929
```
30+
nvim
3031
├── init.lua
3132
├── lazy-lock.json
3233
├── lua
@@ -96,6 +97,7 @@ Inspired by [LazyVim](https://github.com/LazyVim/LazyVim) and [AstroNvim](https:
9697
├── README.md
9798
└── .stylua.toml
9899
```
100+
<!-- PROJECT_STRUCTURE_END -->
99101

100102
### Screenshots
101103

0 commit comments

Comments
 (0)