Skip to content

Instantly share code, notes, and snippets.

@fmal
Created June 6, 2020 10:49
Show Gist options
  • Save fmal/c3066b913c6c8f89a46fa64b927b92f2 to your computer and use it in GitHub Desktop.
Save fmal/c3066b913c6c8f89a46fa64b927b92f2 to your computer and use it in GitHub Desktop.
actions hook
<?php
function process ($collection, $data) {
$collectionsToWatch = ['events'];
if (!in_array($collection, $collectionsToWatch)) {
return;
}
$data = [
'event_type' => 'deploy'
];
$payload = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.github.com/repos/fmal/wyspa-www/dispatches');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Authorization: token ' . $_ENV['GITHUB_TOKEN'],
'Accept: application/vnd.github.everest-preview+json',
'Content-Type: application/json'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_exec($ch);
curl_close($ch);
}
return [
'actions' => [
'item.create' => process,
'item.update' => process,
'item.delete' => process
]
];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment