-
Notifications
You must be signed in to change notification settings - Fork 13
49 lines (41 loc) · 1.5 KB
/
update-readme.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
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