Skip to content

Workflow file for this run

name: Update README with directory tree
on:
push:
branches:
- main
- workflow_testing
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Debug
run: |
echo "Current directory: $(pwd)"
echo "Contents of the current directory: $(ls -al)"
echo "Contents of the repository after checkout: $(ls -al)"
- name: Checkout
uses: actions/checkout@v2
- name: Generate directory tree
run: |
# Generate tree, excluding specified directories
tree -I '.git|node_modules|.github|README.md' > directory_tree.txt
# Check for tree generation errors
if [ ! -s directory_tree.txt ]; then
echo "Error: Directory tree file is empty. Check for issues with the tree command."
exit 1 # Terminate workflow with an error
fi
- name: Update directory tree in README
run: |
# Add new directory tree below the existing # Directory Tree within <details> block
sed -i '/# Directory Tree/,$d' README.md
echo -e "# Directory Tree\n\`\`\`bash" >> README.md
cat directory_tree.txt >> README.md
echo -e "\`\`\`\n" >> README.md
- name: Commit and push changes
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
git add README.md
git commit -m "Update directory tree in README" || true
git push
# nn