updateFromAmdaInternal.php 1.17 KB
<?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);
	  
?>