-
Notifications
You must be signed in to change notification settings - Fork 268
59 lines (49 loc) · 1.83 KB
/
generate_project_tree_structure.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Generate Project Tree
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch: # Allows manual triggering of the workflow
jobs:
generate_tree:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Make script executable
run: chmod +x ./project_tree_directory_util.sh
- name: Delete existing project_tree_structure.txt if it exists
run: |
if [ -f project_tree_structure.txt ]; then
rm project_tree_structure.txt
fi
- name: Generate project tree structure
run: ./project_tree_directory_util.sh > project_tree_structure.txt
- name: Update README with project tree
run: |
# Define the identifier comments
IDENTIFIER="<!-- PROJECT_TREE_START -->"
END_IDENTIFIER="<!-- PROJECT_TREE_END -->"
# Remove old project tree section
sed -i.bak "/$IDENTIFIER/,/$END_IDENTIFIER/d" README.md
# Add new project tree section back in the middle
awk -v identifier="$IDENTIFIER" -v end_identifier="$END_IDENTIFIER" '
{
print $0;
if ($0 ~ identifier) {
print "<summary><h2 align=\"center\">Project Tree Structure 📁</h2> </summary>";
print "```";
system("cat project_tree_structure.txt");
print "```";
}
}' README.md > temp.md && mv temp.md README.md
- name: Commit changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add README.md project_tree_structure.txt
git commit -m "Update project tree structure in README" || echo "No changes to commit"
git push