]> Untitled Git - git-webhooks.git/blob - update-godot-builder.sh
d85754ca0776c08fd6e73108893f0cd7c8f6e8fa
[git-webhooks.git] / update-godot-builder.sh
1 #!/bin/bash
2
3 # Called by "git receive-pack" with arguments: refname sha1-old sha1-new
4 # To enable this hook, rename this file to "update".
5
6 # --- Command line
7 refname="$1"
8 oldrev="$2"
9 newrev="$3"
10
11 # --- Safety check
12 if [[ -z "$GIT_DIR" ]]
13 then
14         echo "Don't run this script from the command line." >&2
15         echo " (if you want, you could supply GIT_DIR then run" >&2
16         echo "  $0 <ref> <oldrev> <newrev>)" >&2
17         exit 1
18 fi
19
20 if [[ -z "$refname" ]] || [[ -z "$oldrev" ]] || [[ -z "$newrev" ]]
21 then
22         echo "usage: $0 <ref> <oldrev> <newrev>" >&2
23         exit 1
24 fi
25
26 # --- Upon branch update, build gitweb snapshot URI
27 # TODO: get project name based on current directory name
28 project_name=wolf-seeking-sheep
29 snapshot_uri=https://git.purplebirdman.com/${project_name}.git/snapshot/${newrev}.tar.gz
30 echo "Snapshot URI - https://git.purplebirdman.com/${project_name}.git/snapshot/${newrev}.tar.gz"
31
32 # --- Now send request to builder service
33 godot_builder_uri=https://godot.purplebirdman.com/hook/make-build-request.lua
34
35 echo "Sending build request..."
36 curl -Ss --get --data-urlencode "snapshot_uri=${snapshot_uri}" $godot_builder_uri
37
38 exit 0