Blame view

updateFromAmdaInternal.php 1.17 KB
7a88f1b3   Elena.Budnik   webhooks
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
41
42
43
44
45
46
<?php

	$json = json_decode(file_get_contents('php://input'), true);
	
	$commits = $json["commits"];
	$updateOnly = false;
	$newData = false;
	$to = "ebudnik@irap.omp.eu";

	
	foreach ($commits as $commit)
	{
		$msg = $commit['message'];
		if ($msg == 'UpdateOnly') 
		{
		  // UpdateAmda 
		  $updateOnly = true;
		  $messageUpdate = "Updates in AMDA_INTERNAL_METADATA.git : without args generation";
		  $subjectUpdate = "AMDA Update Required";
		}
		else if ($msg == 'NewData')
		{
		  // UpdateAmda -i
		  $newData = true;
		  $messageNewData = "New Data in  AMDA_INTERNAL_METADATA.git : with args generation";
		  $subjectNewData = "AMDA Update Required";
		}
		else
		{
		  $message = "Unqualified push in AMDA_INTERNAL_METADATA.git";
		  $subject = "Unqualified push in AMDA_INTERNAL_METADATA.git";
		}
	// error_log($msg,3,'/home/budnik/AMDA/AMDA_IHM/HOOK');
	}

	$headers = "From:AMDA@".gethostname()."\r\nContent-type: text/plain; charset=UTF-8";
	
	if ($updateOnly) 
	  mail($to, $subjectUpdate, $messageUpdate, $headers);
	if ($newData) 
	  mail($to, $subjectNewData, $messageNewData, $headers); 
	
	if (!$updateOnly && !$newData)
		mail($to, $subject, $message, $headers);
	  
?>