[ github ] extract github pr hook using PHP

In github, choose

Content type : application/json

Example code to decode

$data_array = json_decode(file_get_contents( 'php://input' ), true);
$data = var_export($data_array, true);

Example array callback

array (
'action' => 'closed',
'number' => 28,
'pull_request' =>
array (
'url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/pulls/28',
'id' => 297456404,
'node_id' => 'MDExOlB1bGxSZXF1ZXN0Mjk3NDU2NDA0',
'html_url' => 'https://github.com/phong-wildsky/pong-test-repo/pull/28',
'diff_url' => 'https://github.com/phong-wildsky/pong-test-repo/pull/28.diff',
'patch_url' => 'https://github.com/phong-wildsky/pong-test-repo/pull/28.patch',
'issue_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/issues/28',
'number' => 28,
'state' => 'closed',
'locked' => false,
'title' => 'Update README.md',
'user' =>
array (
'login' => 'phong-wildsky',
'id' => 25359460,
'node_id' => 'MDQ6VXNlcjI1MzU5NDYw',
'avatar_url' => 'https://avatars0.githubusercontent.com/u/25359460?v=4',
'gravatar_id' => '',
'url' => 'https://api.github.com/users/phong-wildsky',
'html_url' => 'https://github.com/phong-wildsky',
'followers_url' => 'https://api.github.com/users/phong-wildsky/followers',
'following_url' => 'https://api.github.com/users/phong-wildsky/following{/other_user}',
'gists_url' => 'https://api.github.com/users/phong-wildsky/gists{/gist_id}',
'starred_url' => 'https://api.github.com/users/phong-wildsky/starred{/owner}{/repo}',
'subscriptions_url' => 'https://api.github.com/users/phong-wildsky/subscriptions',
'organizations_url' => 'https://api.github.com/users/phong-wildsky/orgs',
'repos_url' => 'https://api.github.com/users/phong-wildsky/repos',
'events_url' => 'https://api.github.com/users/phong-wildsky/events{/privacy}',
'received_events_url' => 'https://api.github.com/users/phong-wildsky/received_events',
'type' => 'User',
'site_admin' => false,
),
'body' => '29',
'created_at' => '2019-07-15T03:15:50Z',
'updated_at' => '2019-07-15T03:21:37Z',
'closed_at' => '2019-07-15T03:21:37Z',
'merged_at' => '2019-07-15T03:21:37Z',
'merge_commit_sha' => 'a5ca5dda6949ad0f23450de64d1e9c5246985be0',
'assignee' => NULL,
'assignees' =>
array (
),
'requested_reviewers' =>
array (
),
'requested_teams' =>
array (
),
'labels' =>
array (
),
'milestone' => NULL,
'commits_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/pulls/28/commits',
'review_comments_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/pulls/28/comments',
'review_comment_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/pulls/comments{/number}',
'comments_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/issues/28/comments',
'statuses_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/statuses/4176ebb4e8d2c9be5ca39fe719d71ad9c721f0cf',
'head' =>
array (
'label' => 'phong-wildsky:test-branch-29',
'ref' => 'test-branch-29',
'sha' => '4176ebb4e8d2c9be5ca39fe719d71ad9c721f0cf',
'user' =>
array (
'login' => 'phong-wildsky',
'id' => 25359460,
'node_id' => 'MDQ6VXNlcjI1MzU5NDYw',
'avatar_url' => 'https://avatars0.githubusercontent.com/u/25359460?v=4',
'gravatar_id' => '',
'url' => 'https://api.github.com/users/phong-wildsky',
'html_url' => 'https://github.com/phong-wildsky',
'followers_url' => 'https://api.github.com/users/phong-wildsky/followers',
'following_url' => 'https://api.github.com/users/phong-wildsky/following{/other_user}',
'gists_url' => 'https://api.github.com/users/phong-wildsky/gists{/gist_id}',
'starred_url' => 'https://api.github.com/users/phong-wildsky/starred{/owner}{/repo}',
'subscriptions_url' => 'https://api.github.com/users/phong-wildsky/subscriptions',
'organizations_url' => 'https://api.github.com/users/phong-wildsky/orgs',
'repos_url' => 'https://api.github.com/users/phong-wildsky/repos',
'events_url' => 'https://api.github.com/users/phong-wildsky/events{/privacy}',
'received_events_url' => 'https://api.github.com/users/phong-wildsky/received_events',
'type' => 'User',
'site_admin' => false,
),
'repo' =>
array (
'id' => 154774092,
'node_id' => 'MDEwOlJlcG9zaXRvcnkxNTQ3NzQwOTI=',
'name' => 'pong-test-repo',
'full_name' => 'phong-wildsky/pong-test-repo',
'private' => false,
'owner' =>
array (
'login' => 'phong-wildsky',
'id' => 25359460,
'node_id' => 'MDQ6VXNlcjI1MzU5NDYw',
'avatar_url' => 'https://avatars0.githubusercontent.com/u/25359460?v=4',
'gravatar_id' => '',
'url' => 'https://api.github.com/users/phong-wildsky',
'html_url' => 'https://github.com/phong-wildsky',
'followers_url' => 'https://api.github.com/users/phong-wildsky/followers',
'following_url' => 'https://api.github.com/users/phong-wildsky/following{/other_user}',
'gists_url' => 'https://api.github.com/users/phong-wildsky/gists{/gist_id}',
'starred_url' => 'https://api.github.com/users/phong-wildsky/starred{/owner}{/repo}',
'subscriptions_url' => 'https://api.github.com/users/phong-wildsky/subscriptions',
'organizations_url' => 'https://api.github.com/users/phong-wildsky/orgs',
'repos_url' => 'https://api.github.com/users/phong-wildsky/repos',
'events_url' => 'https://api.github.com/users/phong-wildsky/events{/privacy}',
'received_events_url' => 'https://api.github.com/users/phong-wildsky/received_events',
'type' => 'User',
'site_admin' => false,
),
'html_url' => 'https://github.com/phong-wildsky/pong-test-repo',
'description' => NULL,
'fork' => false,
'url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo',
'forks_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/forks',
'keys_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/keys{/key_id}',
'collaborators_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/collaborators{/collaborator}',
'teams_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/teams',
'hooks_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/hooks',
'issue_events_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/issues/events{/number}',
'events_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/events',
'assignees_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/assignees{/user}',
'branches_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/branches{/branch}',
'tags_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/tags',
'blobs_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/blobs{/sha}',
'git_tags_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/tags{/sha}',
'git_refs_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/refs{/sha}',
'trees_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/trees{/sha}',
'statuses_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/statuses/{sha}',
'languages_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/languages',
'stargazers_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/stargazers',
'contributors_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/contributors',
'subscribers_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/subscribers',
'subscription_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/subscription',
'commits_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/commits{/sha}',
'git_commits_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/commits{/sha}',
'comments_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/comments{/number}',
'issue_comment_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/issues/comments{/number}',
'contents_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/contents/{+path}',
'compare_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/compare/{base}...{head}',
'merges_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/merges',
'archive_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/{archive_format}{/ref}',
'downloads_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/downloads',
'issues_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/issues{/number}',
'pulls_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/pulls{/number}',
'milestones_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/milestones{/number}',
'notifications_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/notifications{?since,all,participating}',
'labels_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/labels{/name}',
'releases_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/releases{/id}',
'deployments_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/deployments',
'created_at' => '2018-10-26T03:48:35Z',
'updated_at' => '2019-07-15T03:12:41Z',
'pushed_at' => '2019-07-15T03:21:37Z',
'git_url' => 'git://github.com/phong-wildsky/pong-test-repo.git',
'ssh_url' => 'git@github.com:phong-wildsky/pong-test-repo.git',
'clone_url' => 'https://github.com/phong-wildsky/pong-test-repo.git',
'svn_url' => 'https://github.com/phong-wildsky/pong-test-repo',
'homepage' => NULL,
'size' => 29,
'stargazers_count' => 0,
'watchers_count' => 0,
'language' => NULL,
'has_issues' => true,
'has_projects' => true,
'has_downloads' => true,
'has_wiki' => true,
'has_pages' => false,
'forks_count' => 0,
'mirror_url' => NULL,
'archived' => false,
'disabled' => false,
'open_issues_count' => 2,
'license' => NULL,
'forks' => 0,
'open_issues' => 2,
'watchers' => 0,
'default_branch' => 'master',
),
),
'base' =>
array (
'label' => 'phong-wildsky:master',
'ref' => 'master',
'sha' => 'df9d6ca2a55d5a556af07069fb78cdc8dfee86e6',
'user' =>
array (
'login' => 'phong-wildsky',
'id' => 25359460,
'node_id' => 'MDQ6VXNlcjI1MzU5NDYw',
'avatar_url' => 'https://avatars0.githubusercontent.com/u/25359460?v=4',
'gravatar_id' => '',
'url' => 'https://api.github.com/users/phong-wildsky',
'html_url' => 'https://github.com/phong-wildsky',
'followers_url' => 'https://api.github.com/users/phong-wildsky/followers',
'following_url' => 'https://api.github.com/users/phong-wildsky/following{/other_user}',
'gists_url' => 'https://api.github.com/users/phong-wildsky/gists{/gist_id}',
'starred_url' => 'https://api.github.com/users/phong-wildsky/starred{/owner}{/repo}',
'subscriptions_url' => 'https://api.github.com/users/phong-wildsky/subscriptions',
'organizations_url' => 'https://api.github.com/users/phong-wildsky/orgs',
'repos_url' => 'https://api.github.com/users/phong-wildsky/repos',
'events_url' => 'https://api.github.com/users/phong-wildsky/events{/privacy}',
'received_events_url' => 'https://api.github.com/users/phong-wildsky/received_events',
'type' => 'User',
'site_admin' => false,
),
'repo' =>
array (
'id' => 154774092,
'node_id' => 'MDEwOlJlcG9zaXRvcnkxNTQ3NzQwOTI=',
'name' => 'pong-test-repo',
'full_name' => 'phong-wildsky/pong-test-repo',
'private' => false,
'owner' =>
array (
'login' => 'phong-wildsky',
'id' => 25359460,
'node_id' => 'MDQ6VXNlcjI1MzU5NDYw',
'avatar_url' => 'https://avatars0.githubusercontent.com/u/25359460?v=4',
'gravatar_id' => '',
'url' => 'https://api.github.com/users/phong-wildsky',
'html_url' => 'https://github.com/phong-wildsky',
'followers_url' => 'https://api.github.com/users/phong-wildsky/followers',
'following_url' => 'https://api.github.com/users/phong-wildsky/following{/other_user}',
'gists_url' => 'https://api.github.com/users/phong-wildsky/gists{/gist_id}',
'starred_url' => 'https://api.github.com/users/phong-wildsky/starred{/owner}{/repo}',
'subscriptions_url' => 'https://api.github.com/users/phong-wildsky/subscriptions',
'organizations_url' => 'https://api.github.com/users/phong-wildsky/orgs',
'repos_url' => 'https://api.github.com/users/phong-wildsky/repos',
'events_url' => 'https://api.github.com/users/phong-wildsky/events{/privacy}',
'received_events_url' => 'https://api.github.com/users/phong-wildsky/received_events',
'type' => 'User',
'site_admin' => false,
),
'html_url' => 'https://github.com/phong-wildsky/pong-test-repo',
'description' => NULL,
'fork' => false,
'url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo',
'forks_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/forks',
'keys_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/keys{/key_id}',
'collaborators_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/collaborators{/collaborator}',
'teams_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/teams',
'hooks_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/hooks',
'issue_events_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/issues/events{/number}',
'events_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/events',
'assignees_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/assignees{/user}',
'branches_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/branches{/branch}',
'tags_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/tags',
'blobs_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/blobs{/sha}',
'git_tags_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/tags{/sha}',
'git_refs_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/refs{/sha}',
'trees_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/trees{/sha}',
'statuses_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/statuses/{sha}',
'languages_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/languages',
'stargazers_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/stargazers',
'contributors_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/contributors',
'subscribers_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/subscribers',
'subscription_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/subscription',
'commits_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/commits{/sha}',
'git_commits_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/git/commits{/sha}',
'comments_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/comments{/number}',
'issue_comment_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/issues/comments{/number}',
'contents_url' => 'https://api.github.com/repos/phong-wildsky/pong-test-repo/contents/{+path}',
'compare_url'...(length 28436)

ref : https://developer.github.com/v3/activity/events/types/#pullrequestevent

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s