diff --git a/webhooks-git/Dockerfile b/webhooks-git/Dockerfile
index 33605b7..112731f 100644
--- a/webhooks-git/Dockerfile
+++ b/webhooks-git/Dockerfile
@@ -37,6 +37,9 @@ RUN chmod +x /etc/webhook/programm-hook.sh
COPY programm-init.sh /etc/webhook/programm-init.sh
RUN chmod +x /etc/webhook/programm-init.sh
+COPY generate_index_html.sh /etc/webhook/generate_index_html.sh
+RUN chmod +x /etc/webhook/generate_index_html.sh
+
WORKDIR /etc/webhook
EXPOSE 9000
diff --git a/webhooks-git/assets-hook.sh b/webhooks-git/assets-hook.sh
index 8b13789..05a7907 100644
--- a/webhooks-git/assets-hook.sh
+++ b/webhooks-git/assets-hook.sh
@@ -1 +1,2 @@
+#!/bin/bash
diff --git a/webhooks-git/entrypoint.sh b/webhooks-git/entrypoint.sh
index 646d189..af1a291 100644
--- a/webhooks-git/entrypoint.sh
+++ b/webhooks-git/entrypoint.sh
@@ -108,6 +108,9 @@ echo "Initialize assets directory"
echo "Initialize branches of programm"
./programm-init.sh
+# Generate index.html
+./generate_index_html.sh
+
#
# Start webhooks
#
diff --git a/webhooks-git/generate_index_html.sh b/webhooks-git/generate_index_html.sh
new file mode 100644
index 0000000..eee4ac7
--- /dev/null
+++ b/webhooks-git/generate_index_html.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+
+# Directory where branches are stored
+BRANCHES_DIR="/html/branches"
+
+# Generate index.html file
+generate_index_html() {
+ cat << EOF
+
+
+
+
+
+ List of Branches
+
+
+ List of Branches
+
+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 " - $branch_name
"
+ fi
+ done
+
+ cat << EOF
+
+
+
+EOF
+}
+
+generate_index_html > /html/index.html
\ No newline at end of file
diff --git a/webhooks-git/hooks.json.tmpl b/webhooks-git/hooks.json.tmpl
index 01cf15a..6cd652a 100644
--- a/webhooks-git/hooks.json.tmpl
+++ b/webhooks-git/hooks.json.tmpl
@@ -1,7 +1,7 @@
[
{
"id": "programm-webhook",
- "http-methods": ["PUSH"],
+ "http-methods": ["POST"],
"execute-command": "/etc/webhook/programm-hook.sh",
"command-working-directory": "/etc/webhook/",
"response-message": "I got the payload!",
@@ -31,7 +31,7 @@
"match":
{
"type": "payload-hmac-sha1",
- "secret": "1234",
+ "secret": "${WEBHOOK_SECRET}",
"parameter":
{
"source": "header",
@@ -44,6 +44,7 @@
},
{
"id": "assets-webhook",
+ "http-methods": ["POST"],
"execute-command": "/etc/webhook/assets-hook.sh",
"command-working-directory": "/etc/webhook/",
"response-message": "I got the payload!",
@@ -73,7 +74,7 @@
"match":
{
"type": "payload-hmac-sha256",
- "secret": "1234",
+ "secret": "${WEBHOOK_SECRET}",
"parameter":
{
"source": "header",
diff --git a/webhooks-git/programm-hook.sh b/webhooks-git/programm-hook.sh
index e69de29..e4ab640 100644
--- a/webhooks-git/programm-hook.sh
+++ b/webhooks-git/programm-hook.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+# Check if correct number of arguments are provided
+if [ "$#" -ne 2 ]; then
+ echo "Usage: $0 "
+ exit 1
+fi
+
+repository_name="$1"
+branch_name=(basename "$2")
+
+BRANCHES_FOLDER="/html/branches"
+PROGRAMM_REPOSITORY="git_programm:AG-Programm/parteiprogramm.git"
+
+# Echo parameters
+echo "Webhook recieved for repository: $repository_name and branch: $branch_name"
+
+# Check if the branch directory exists
+branch_dir="$BRANCES_FOLDER/$(basename "$branch_name")"
+if [ -d "$branch_dir" ]; then
+ echo "Directory $branch_dir exists, performing git pull..."
+ # Change directory to branch directory
+ cd "$branch_dir"
+ # Perform git pull
+ echo "Updating $branch_dir"
+ git pull origin "$(basename "$branch_name")"
+else
+ echo "Directory $branch_dir does not exist, cloning branch..."
+ # Create branches directory if it doesn't exist
+ mkdir -p branches
+ # Clone the branch
+ git clone --depth 1 --branch "$branch_name" --single-branch "$PROGRAMM_REPOSITORY" "$branch_dir"
+ # reinitialize index.html
+ ./generate_index_html.sh
+fi
diff --git a/webhooks-git/programm-init.sh b/webhooks-git/programm-init.sh
index fdcb9fe..ca207be 100644
--- a/webhooks-git/programm-init.sh
+++ b/webhooks-git/programm-init.sh
@@ -37,8 +37,6 @@ git ls-remote --heads "$PROGRAMM_REPOSITORY" |
# Store branch names in an array
mapfile -t branches
-
-
for branch in "${branches[@]}";
do
echo "cloning $branch"