diff options
author | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-18 22:02:26 +0100 |
---|---|---|
committer | Johannes Stoelp <johannes.stoelp@gmail.com> | 2024-12-18 22:02:26 +0100 |
commit | 84a90cd5dfb885bc3f48ab71c19d06271754c062 (patch) | |
tree | c791ff173be4d2a260e12101a2fb908fc3bdea0a /roles/git/files/runner-zola | |
parent | 55d83176df99449d51497cdaf27e23fd24e17946 (diff) | |
download | ansible-memzero-main.tar.gz ansible-memzero-main.zip |
Diffstat (limited to 'roles/git/files/runner-zola')
-rwxr-xr-x | roles/git/files/runner-zola/webhook.sh | 33 |
1 files changed, 7 insertions, 26 deletions
diff --git a/roles/git/files/runner-zola/webhook.sh b/roles/git/files/runner-zola/webhook.sh index b874233..b009c63 100755 --- a/roles/git/files/runner-zola/webhook.sh +++ b/roles/git/files/runner-zola/webhook.sh @@ -4,8 +4,8 @@ # The webhook allows to pass an optional ref as url path. # # Examples: -# curl <host> ; Will deploy main ref -# curl <host>/blub ; Will deploy blub ref +# curl <host> ; Will deploy origin/main ref +# curl <host>/blub ; Will deploy origin/blub ref while true; do echo "Wait for webhook trigger ..." @@ -15,34 +15,15 @@ while true; do # GET /blub HTTP/1.1 REF=$(echo -e "HTTP/1.0 204 No Content\r\nConnection: close\r\n\r" | nc -l -p 80 | awk '/GET/ { print $2; }' | tr -d '/') # If we got a ref use it else default to main. - REF=${REF:-main} + REF=origin/${REF:-main} if [ ! -d blog ]; then - # Use non-redirected port to clone repository as the runner executes on - # the same machine as the webserver. - # - # We use a NAT:PREROUTING chain to implement the redirection (dnat). - # However as described by the netfilter packet flow and the connection - # tracking system (CONNTRACK), the NAT hooks are only traversed for NEW - # connections. - # For packages originating from the local machine, the connection will - # be seen as NEW by the CONNTRACK system on the OUTPUT path and hence - # the NAT:OUTPUT hooks will be traversed. - # Once the package is looped-back and arrives at the PREROUTING path, - # the NAT:PREROUTING rules wont be traversed as the package is already - # known to the CONNTRACK system (not NEW). - # - # We could additionally implement dnat for lo interface on the OUTPUT - # path as described here, but we dont do it and just use the actual - # port here :^) - # https://unix.stackexchange.com/questions/618229/nftables-destination-nat-block-local-access-to-port - git clone https://git.memzero.de:8443/blog + # Clone through podman network. + git clone http://cgito/blog fi - git -C blog submodule init - git -C blog submodule update git -C blog fetch --prune - echo "Checking out ref: $REF" - git -C blog checkout $REF || continue + echo "Checking out & deploying ref: $REF" + git -C blog checkout --quiet $REF || continue zola --root blog build || continue |