@kyanny's blog

My thoughts, my life. Views/opinions are my own.

GitHub の issue に label をつけたときに飛ぶ webhook

  • Issues event を選ぶとこの webhook が飛ぶ https://developer.github.com/webhooks/
  • イシューを新規作成するときにラベルをつけても ok
  • ラベルを複数つけると webhook も付けたラベルと同じ数だけ飛ぶ
  • webhook payload の label に付与されたラベルの情報が入る(ラベル名は label.name に入る) https://developer.github.com/v3/activity/events/types/#issuesevent
  • labels にはそのイシューについている全てのラベルの情報が入る
    • Array/List で入るので、これをうまくデータ構造としてパースできないクライアントもある。 Zapier とか。

Headers

Request URL: https://requestb.in/11bqcme1
Request method: POST
content-type: application/json
Expect: 
User-Agent: GitHub-Hookshot/eba7944
X-GitHub-Delivery: a549c020-6645-11e7-9dac-30a99e652a6c
X-GitHub-Event: issues

Payload

{
  "action": "labeled",
  "issue": {
    "url": "https://api.github.com/repos/kyanny/test/issues/9",
    "repository_url": "https://api.github.com/repos/kyanny/test",
    "labels_url": "https://api.github.com/repos/kyanny/test/issues/9/labels{/name}",
    "comments_url": "https://api.github.com/repos/kyanny/test/issues/9/comments",
    "events_url": "https://api.github.com/repos/kyanny/test/issues/9/events",
    "html_url": "https://github.com/kyanny/test/issues/9",
    "id": 242069249,
    "number": 9,
    "title": "test",
    "user": {
      "login": "kyanny",
      "id": 10515,
      "avatar_url": "https://avatars0.githubusercontent.com/u/10515?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/kyanny",
      "html_url": "https://github.com/kyanny",
      "followers_url": "https://api.github.com/users/kyanny/followers",
      "following_url": "https://api.github.com/users/kyanny/following{/other_user}",
      "gists_url": "https://api.github.com/users/kyanny/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/kyanny/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/kyanny/subscriptions",
      "organizations_url": "https://api.github.com/users/kyanny/orgs",
      "repos_url": "https://api.github.com/users/kyanny/repos",
      "events_url": "https://api.github.com/users/kyanny/events{/privacy}",
      "received_events_url": "https://api.github.com/users/kyanny/received_events",
      "type": "User",
      "site_admin": false
    },
    "labels": [
      {
        "id": 12613657,
        "url": "https://api.github.com/repos/kyanny/test/labels/bug",
        "name": "bug",
        "color": "fc2929",
        "default": true
      },
      {
        "id": 12613658,
        "url": "https://api.github.com/repos/kyanny/test/labels/duplicate",
        "name": "duplicate",
        "color": "cccccc",
        "default": true
      }
    ],
    "state": "open",
    "locked": false,
    "assignee": null,
    "assignees": [

    ],
    "milestone": null,
    "comments": 0,
    "created_at": "2017-07-11T14:31:36Z",
    "updated_at": "2017-07-11T14:31:36Z",
    "closed_at": null,
    "body": ""
  },
  "label": {
    "id": 12613657,
    "url": "https://api.github.com/repos/kyanny/test/labels/bug",
    "name": "bug",
    "color": "fc2929",
    "default": true
  },
  "repository": {
    "id": 5584868,
    "name": "test",
    "full_name": "kyanny/test",
    "owner": {
      "login": "kyanny",
      "id": 10515,
      "avatar_url": "https://avatars0.githubusercontent.com/u/10515?v=3",
      "gravatar_id": "",
      "url": "https://api.github.com/users/kyanny",
      "html_url": "https://github.com/kyanny",
      "followers_url": "https://api.github.com/users/kyanny/followers",
      "following_url": "https://api.github.com/users/kyanny/following{/other_user}",
      "gists_url": "https://api.github.com/users/kyanny/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/kyanny/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/kyanny/subscriptions",
      "organizations_url": "https://api.github.com/users/kyanny/orgs",
      "repos_url": "https://api.github.com/users/kyanny/repos",
      "events_url": "https://api.github.com/users/kyanny/events{/privacy}",
      "received_events_url": "https://api.github.com/users/kyanny/received_events",
      "type": "User",
      "site_admin": false
    },
    "private": false,
    "html_url": "https://github.com/kyanny/test",
    "description": null,
    "fork": false,
    "url": "https://api.github.com/repos/kyanny/test",
    "forks_url": "https://api.github.com/repos/kyanny/test/forks",
    "keys_url": "https://api.github.com/repos/kyanny/test/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/kyanny/test/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/kyanny/test/teams",
    "hooks_url": "https://api.github.com/repos/kyanny/test/hooks",
    "issue_events_url": "https://api.github.com/repos/kyanny/test/issues/events{/number}",
    "events_url": "https://api.github.com/repos/kyanny/test/events",
    "assignees_url": "https://api.github.com/repos/kyanny/test/assignees{/user}",
    "branches_url": "https://api.github.com/repos/kyanny/test/branches{/branch}",
    "tags_url": "https://api.github.com/repos/kyanny/test/tags",
    "blobs_url": "https://api.github.com/repos/kyanny/test/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/kyanny/test/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/kyanny/test/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/kyanny/test/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/kyanny/test/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/kyanny/test/languages",
    "stargazers_url": "https://api.github.com/repos/kyanny/test/stargazers",
    "contributors_url": "https://api.github.com/repos/kyanny/test/contributors",
    "subscribers_url": "https://api.github.com/repos/kyanny/test/subscribers",
    "subscription_url": "https://api.github.com/repos/kyanny/test/subscription",
    "commits_url": "https://api.github.com/repos/kyanny/test/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/kyanny/test/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/kyanny/test/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/kyanny/test/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/kyanny/test/contents/{+path}",
    "compare_url": "https://api.github.com/repos/kyanny/test/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/kyanny/test/merges",
    "archive_url": "https://api.github.com/repos/kyanny/test/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/kyanny/test/downloads",
    "issues_url": "https://api.github.com/repos/kyanny/test/issues{/number}",
    "pulls_url": "https://api.github.com/repos/kyanny/test/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/kyanny/test/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/kyanny/test/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/kyanny/test/labels{/name}",
    "releases_url": "https://api.github.com/repos/kyanny/test/releases{/id}",
    "deployments_url": "https://api.github.com/repos/kyanny/test/deployments",
    "created_at": "2012-08-28T11:26:35Z",
    "updated_at": "2017-06-17T17:34:36Z",
    "pushed_at": "2017-06-17T17:34:35Z",
    "git_url": "git://github.com/kyanny/test.git",
    "ssh_url": "git@github.com:kyanny/test.git",
    "clone_url": "https://github.com/kyanny/test.git",
    "svn_url": "https://github.com/kyanny/test",
    "homepage": null,
    "size": 6,
    "stargazers_count": 0,
    "watchers_count": 0,
    "language": "Ruby",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": true,
    "forks_count": 0,
    "mirror_url": null,
    "open_issues_count": 3,
    "forks": 0,
    "open_issues": 3,
    "watchers": 0,
    "default_branch": "master"
  },
  "sender": {
    "login": "kyanny",
    "id": 10515,
    "avatar_url": "https://avatars0.githubusercontent.com/u/10515?v=3",
    "gravatar_id": "",
    "url": "https://api.github.com/users/kyanny",
    "html_url": "https://github.com/kyanny",
    "followers_url": "https://api.github.com/users/kyanny/followers",
    "following_url": "https://api.github.com/users/kyanny/following{/other_user}",
    "gists_url": "https://api.github.com/users/kyanny/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/kyanny/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/kyanny/subscriptions",
    "organizations_url": "https://api.github.com/users/kyanny/orgs",
    "repos_url": "https://api.github.com/users/kyanny/repos",
    "events_url": "https://api.github.com/users/kyanny/events{/privacy}",
    "received_events_url": "https://api.github.com/users/kyanny/received_events",
    "type": "User",
    "site_admin": false
  }
}