programm-webhook/webhooks-git/generate_index_html.sh

36 lines
833 B
Bash

#!/bin/bash
# Directory where branches are stored
BRANCHES_DIR="/html/branches"
# Generate index.html file
generate_index_html() {
cat << EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>List of Branches</title>
</head>
<body>
<h1>List of Branches</h1>
<ul>
EOF
# Loop through folders in ./branches/ excluding "assets"
for branch_folder in "$BRANCHES_DIR"/*; do
branch_name=$(basename "$branch_folder")
if [ "$branch_name" != "assets" ] && [ -f "$branch_folder/index.html" ]; then
echo " <li><a href=\"branches/$branch_name/index.html\">$branch_name</a></li>"
fi
done
cat << EOF
</ul>
</body>
</html>
EOF
}
generate_index_html > /html/index.html