diff --git a/src/etc/webhook/hooks.yaml b/src/etc/webhook/hooks.yaml new file mode 100644 index 0000000..e109613 --- /dev/null +++ b/src/etc/webhook/hooks.yaml @@ -0,0 +1,24 @@ +- id: deploy + execute-command: "/var/ingress.tjo.cloud/src/install.sh" + command-working-directory: "/var/ingress.tjo.cloud/" + pass-arguments-to-command: + - source: payload + name: "head_commit.id" + - source: payload + name: "pusher.name" + - source: payload + name: "pusher.email" + trigger-rule: + and: + - match: + type: payload-hmac-sha256 + secret: "FIGURE_OUT_HOW_TO_SET_THIS" + parameter: + source: header + name: X-Forgejo-Signature + - match: + type: value + value: "push" + parameter: + source: ref + ref: "ref/heads/main" diff --git a/src/install.sh b/src/install.sh new file mode 100755 index 0000000..be5f1d0 --- /dev/null +++ b/src/install.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +## +# Dependencies +apt update -y + +apt install -y \ + git \ + webhook \ + nginx \ + nginx-extras \ + libnginx-mod-http-geoip2 \ + libnginx-mod-stream-geoip2 + +## +# Copy Sysmtemd service/units +cp -r etc/systemd/* /etc/systemd/ + +## +# Ensure services are enabled +systemctl enable --now nginx webhook + +## +# Configure NGINX +cp -r etc/nginx/* /etc/nginx/ +systemctl reload nginx + +## +# Configure Webhook +cp -r etc/webhook/* /etc/webhook/ +systemctl reload webhook diff --git a/src/systemd/system/geo-ip-update.timer b/src/systemd/system/geo-ip-update.timer new file mode 100644 index 0000000..e69de29 diff --git a/src/systemd/system/webhook.service b/src/systemd/system/webhook.service new file mode 100644 index 0000000..5aa7b0f --- /dev/null +++ b/src/systemd/system/webhook.service @@ -0,0 +1,8 @@ +[Unit] +Description=Webhooks + +[Service] +ExecStart=/usr/bin/webhook -hooks /etc/webhook/hooks.json -port 7777 -verbose + +[Install] +WantedBy=multi-user.target