Skip to content

Update README.md

Update README.md #12

name: Generate Project Tree
on:
push:
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: 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: tree > project_tree_structure.txt
- name: Update README with project tree
run: |
# Define the identifier comment
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
echo "$IDENTIFIER" >> README.md
echo '<details close>' >> README.md
echo '<summary><h2 align="center">Project Tree Structure 📁</h2> </summary>' >> README.md
echo ''
echo '```plaintext' >> README.md
cat project_tree_structure.txt >> README.md
echo '```' >> README.md
echo "$END_IDENTIFIER" >> 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