-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathupdate_wiki.sh
More file actions
executable file
·76 lines (59 loc) · 1.71 KB
/
update_wiki.sh
File metadata and controls
executable file
·76 lines (59 loc) · 1.71 KB
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
# Exit on error
set -e
# Configuration - update these for your deployment
WIKI_REPO="git@github.com:CroodSolutions/CISOinaBox.wiki.git"
TMP_DIR="temp_wiki"
# Clone the wiki repository
echo "Cloning wiki repository..."
rm -rf $TMP_DIR
git clone $WIKI_REPO $TMP_DIR
# Enter the wiki directory
cd $TMP_DIR
# Clear existing content
echo "Clearing existing wiki content..."
find . -name "*.md" -type f -delete
# Generate a sidebar
echo "Generating sidebar..."
echo "### CISO in a Box" > _Sidebar.md
echo "" >> _Sidebar.md
echo "* [Home](Home)" >> _Sidebar.md
echo "* [Contributing](Contributing)" >> _Sidebar.md
# Copy and rename files
echo "Copying and renaming files..."
for dir in ../[0-9]*; do
if [ -d "$dir" ]; then
# Get the directory name without the path
dir_name=$(basename "$dir")
# Find the readme file (case-insensitive)
readme_file=$(find "$dir" -maxdepth 1 -iname "Readme.md")
if [ -f "$readme_file" ]; then
# Create a wiki-friendly name
wiki_name=$(echo "$dir_name" | sed 's/ /-/g' | sed 's/---/-/g')
# Copy the file
cp "$readme_file" "${wiki_name}.md"
# Add to sidebar
echo "* [${dir_name}](${wiki_name})" >> _Sidebar.md
fi
fi
done
# Copy contributing guide
if [ -f "../CONTRIBUTING.md" ]; then
cp "../CONTRIBUTING.md" "Contributing.md"
fi
# Create a Home page from the main README if available
if [ -f "../README.md" ]; then
cp "../README.md" "Home.md"
else
echo "CISO in a Box" > Home.md
fi
# Commit and push changes
echo "Committing and pushing changes..."
git add .
git commit -m "Update wiki from repository"
git push origin master
# Clean up
echo "Cleaning up..."
cd ..
rm -rf $TMP_DIR
echo "Wiki update complete!"