summaryrefslogtreecommitdiff
path: root/playbooks/roles/src/templates/volumes/soft-serve/hooks/update
blob: c44698d29519c54af31c0ec7a5118bf643516564 (plain)
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
#!/bin/bash

# -- <logo> --
function logo() {
    git config --global color.ui auto

cat <<'EOF'
{{ logo }}
EOF
}
# -- </logo> --

# -- <continuous_integration> --
refname="$1"
_oldrev="$2"
rev="$3"

post_trigger_ci_jobs() {
    local host="ci_server"
    local port="9000"
    local path="/job"
    local json_payload=$(printf '{"type": "ci_pipeline", "arguments": {"remote": "%s", "rev": "%s", "refname": "%s"}}' "$1" "$2" "$3")

    which curl 2&>/dev/null || apk add -q curl
    curl -X POST \
         -H "Content-Type: application/json" \
         -H "Connection: close" \
         -d "$json_payload" \
         --no-progress-meter \
         "http://$host:$port$path"

}
# -- </continuous_integration> --

# -- <main> --
remote="ssh://{{ src_domain }}:2222/$(basename "$PWD")"

logo
post_trigger_ci_jobs "$remote" "$rev" "$refname"
# -- </main> --