]> Untitled Git - git-webhooks.git/blob - update-godot-builder.sh
Get project name based on current directory
[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 git_project_name=$(pwd | grep -o '[a-zA-Z0-9-]*\.git')
28 echo "Git project name - $git_project_name"
29
30 snapshot_uri=https://git.purplebirdman.com/${git_project_name}/snapshot/${newrev}.tar.gz
31 echo "Snapshot URI - $snapshot_uri"
32
33 # --- Now send request to builder service
34 godot_builder_uri=https://godot.purplebirdman.com/hook/make-build-request.lua
35
36 echo "Sending build request..."
37 curl -Ss --get --data-urlencode "snapshot_uri=${snapshot_uri}" $godot_builder_uri
38
39 exit 0