tracehubpm / tracehub

Tracehub and Project as a Code, a VCS-based collaboration tool
MIT License
5 stars 0 forks source link

GitHub issues webhook input parsing #118

Closed h1alexbel closed 5 months ago

h1alexbel commented 5 months ago

we should parse the following payload we receive from GitHub issues webhook:

{
  "action": "opened",
  "issue": {
    "url": "https://api.github.com/repos/h1alexbel/cdit/issues/48",
    "repository_url": "https://api.github.com/repos/h1alexbel/cdit",
    "labels_url": "https://api.github.com/repos/h1alexbel/cdit/issues/48/labels{/name}",
    "comments_url": "https://api.github.com/repos/h1alexbel/cdit/issues/48/comments",
    "events_url": "https://api.github.com/repos/h1alexbel/cdit/issues/48/events",
    "html_url": "https://github.com/h1alexbel/cdit/issues/48",
    "id": 2110114087,
    "node_id": "I_kwDOK2aoDM59xckn",
    "number": 48,
    "title": "test issue",
    "user": {
      "login": "h1alexbel",
      "id": 83453843,
      "node_id": "MDQ6VXNlcjgzNDUzODQz",
      "avatar_url": "https://avatars.githubusercontent.com/u/83453843?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/h1alexbel",
      "html_url": "https://github.com/h1alexbel",
      "followers_url": "https://api.github.com/users/h1alexbel/followers",
      "following_url": "https://api.github.com/users/h1alexbel/following{/other_user}",
      "gists_url": "https://api.github.com/users/h1alexbel/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/h1alexbel/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/h1alexbel/subscriptions",
      "organizations_url": "https://api.github.com/users/h1alexbel/orgs",
      "repos_url": "https://api.github.com/users/h1alexbel/repos",
      "events_url": "https://api.github.com/users/h1alexbel/events{/privacy}",
      "received_events_url": "https://api.github.com/users/h1alexbel/received_events",
      "type": "User",
      "site_admin": false
    },
    "labels": [

    ],
    "state": "open",
    "locked": false,
    "assignee": null,
    "assignees": [

    ],
    "milestone": null,
    "comments": 0,
    "created_at": "2024-01-31T13:36:21Z",
    "updated_at": "2024-01-31T13:36:21Z",
    "closed_at": null,
    "author_association": "OWNER",
    "active_lock_reason": null,
    "body": null,
    "reactions": {
      "url": "https://api.github.com/repos/h1alexbel/cdit/issues/48/reactions",
      "total_count": 0,
      "+1": 0,
      "-1": 0,
      "laugh": 0,
      "hooray": 0,
      "confused": 0,
      "heart": 0,
      "rocket": 0,
      "eyes": 0
    },
    "timeline_url": "https://api.github.com/repos/h1alexbel/cdit/issues/48/timeline",
    "performed_via_github_app": null,
    "state_reason": null
  },
  "repository": {
    "id": 728147980,
    "node_id": "R_kgDOK2aoDA",
    "name": "cdit",
    "full_name": "h1alexbel/cdit",
    "private": false,
    "owner": {
      "login": "h1alexbel",
      "id": 83453843,
      "node_id": "MDQ6VXNlcjgzNDUzODQz",
      "avatar_url": "https://avatars.githubusercontent.com/u/83453843?v=4",
      "gravatar_id": "",
      "url": "https://api.github.com/users/h1alexbel",
      "html_url": "https://github.com/h1alexbel",
      "followers_url": "https://api.github.com/users/h1alexbel/followers",
      "following_url": "https://api.github.com/users/h1alexbel/following{/other_user}",
      "gists_url": "https://api.github.com/users/h1alexbel/gists{/gist_id}",
      "starred_url": "https://api.github.com/users/h1alexbel/starred{/owner}{/repo}",
      "subscriptions_url": "https://api.github.com/users/h1alexbel/subscriptions",
      "organizations_url": "https://api.github.com/users/h1alexbel/orgs",
      "repos_url": "https://api.github.com/users/h1alexbel/repos",
      "events_url": "https://api.github.com/users/h1alexbel/events{/privacy}",
      "received_events_url": "https://api.github.com/users/h1alexbel/received_events",
      "type": "User",
      "site_admin": false
    },
    "html_url": "https://github.com/h1alexbel/cdit",
    "description": "A Collection of Pre-Configured Docker Containers for your Integration Tests",
    "fork": false,
    "url": "https://api.github.com/repos/h1alexbel/cdit",
    "forks_url": "https://api.github.com/repos/h1alexbel/cdit/forks",
    "keys_url": "https://api.github.com/repos/h1alexbel/cdit/keys{/key_id}",
    "collaborators_url": "https://api.github.com/repos/h1alexbel/cdit/collaborators{/collaborator}",
    "teams_url": "https://api.github.com/repos/h1alexbel/cdit/teams",
    "hooks_url": "https://api.github.com/repos/h1alexbel/cdit/hooks",
    "issue_events_url": "https://api.github.com/repos/h1alexbel/cdit/issues/events{/number}",
    "events_url": "https://api.github.com/repos/h1alexbel/cdit/events",
    "assignees_url": "https://api.github.com/repos/h1alexbel/cdit/assignees{/user}",
    "branches_url": "https://api.github.com/repos/h1alexbel/cdit/branches{/branch}",
    "tags_url": "https://api.github.com/repos/h1alexbel/cdit/tags",
    "blobs_url": "https://api.github.com/repos/h1alexbel/cdit/git/blobs{/sha}",
    "git_tags_url": "https://api.github.com/repos/h1alexbel/cdit/git/tags{/sha}",
    "git_refs_url": "https://api.github.com/repos/h1alexbel/cdit/git/refs{/sha}",
    "trees_url": "https://api.github.com/repos/h1alexbel/cdit/git/trees{/sha}",
    "statuses_url": "https://api.github.com/repos/h1alexbel/cdit/statuses/{sha}",
    "languages_url": "https://api.github.com/repos/h1alexbel/cdit/languages",
    "stargazers_url": "https://api.github.com/repos/h1alexbel/cdit/stargazers",
    "contributors_url": "https://api.github.com/repos/h1alexbel/cdit/contributors",
    "subscribers_url": "https://api.github.com/repos/h1alexbel/cdit/subscribers",
    "subscription_url": "https://api.github.com/repos/h1alexbel/cdit/subscription",
    "commits_url": "https://api.github.com/repos/h1alexbel/cdit/commits{/sha}",
    "git_commits_url": "https://api.github.com/repos/h1alexbel/cdit/git/commits{/sha}",
    "comments_url": "https://api.github.com/repos/h1alexbel/cdit/comments{/number}",
    "issue_comment_url": "https://api.github.com/repos/h1alexbel/cdit/issues/comments{/number}",
    "contents_url": "https://api.github.com/repos/h1alexbel/cdit/contents/{+path}",
    "compare_url": "https://api.github.com/repos/h1alexbel/cdit/compare/{base}...{head}",
    "merges_url": "https://api.github.com/repos/h1alexbel/cdit/merges",
    "archive_url": "https://api.github.com/repos/h1alexbel/cdit/{archive_format}{/ref}",
    "downloads_url": "https://api.github.com/repos/h1alexbel/cdit/downloads",
    "issues_url": "https://api.github.com/repos/h1alexbel/cdit/issues{/number}",
    "pulls_url": "https://api.github.com/repos/h1alexbel/cdit/pulls{/number}",
    "milestones_url": "https://api.github.com/repos/h1alexbel/cdit/milestones{/number}",
    "notifications_url": "https://api.github.com/repos/h1alexbel/cdit/notifications{?since,all,participating}",
    "labels_url": "https://api.github.com/repos/h1alexbel/cdit/labels{/name}",
    "releases_url": "https://api.github.com/repos/h1alexbel/cdit/releases{/id}",
    "deployments_url": "https://api.github.com/repos/h1alexbel/cdit/deployments",
    "created_at": "2023-12-06T10:29:59Z",
    "updated_at": "2023-12-12T07:38:39Z",
    "pushed_at": "2024-01-30T00:34:34Z",
    "git_url": "git://github.com/h1alexbel/cdit.git",
    "ssh_url": "git@github.com:h1alexbel/cdit.git",
    "clone_url": "https://github.com/h1alexbel/cdit.git",
    "svn_url": "https://github.com/h1alexbel/cdit",
    "homepage": "",
    "size": 60,
    "stargazers_count": 6,
    "watchers_count": 6,
    "language": "Java",
    "has_issues": true,
    "has_projects": true,
    "has_downloads": true,
    "has_wiki": true,
    "has_pages": false,
    "has_discussions": false,
    "forks_count": 0,
    "mirror_url": null,
    "archived": false,
    "disabled": false,
    "open_issues_count": 7,
    "license": {
      "key": "mit",
      "name": "MIT License",
      "spdx_id": "MIT",
      "url": "https://api.github.com/licenses/mit",
      "node_id": "MDc6TGljZW5zZTEz"
    },
    "allow_forking": true,
    "is_template": false,
    "web_commit_signoff_required": false,
    "topics": [
      "docker",
      "integration-testing",
      "java",
      "testcontainers"
    ],
    "visibility": "public",
    "forks": 0,
    "open_issues": 7,
    "watchers": 6,
    "default_branch": "master"
  },
  "sender": {
    "login": "h1alexbel",
    "id": 83453843,
    "node_id": "MDQ6VXNlcjgzNDUzODQz",
    "avatar_url": "https://avatars.githubusercontent.com/u/83453843?v=4",
    "gravatar_id": "",
    "url": "https://api.github.com/users/h1alexbel",
    "html_url": "https://github.com/h1alexbel",
    "followers_url": "https://api.github.com/users/h1alexbel/followers",
    "following_url": "https://api.github.com/users/h1alexbel/following{/other_user}",
    "gists_url": "https://api.github.com/users/h1alexbel/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/h1alexbel/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/h1alexbel/subscriptions",
    "organizations_url": "https://api.github.com/users/h1alexbel/orgs",
    "repos_url": "https://api.github.com/users/h1alexbel/repos",
    "events_url": "https://api.github.com/users/h1alexbel/events{/privacy}",
    "received_events_url": "https://api.github.com/users/h1alexbel/received_events",
    "type": "User",
    "site_admin": false
  }
}

first things we need to do is to check the creator of the issue, if its not a @tracehubgit then we can process this payload.

h1alexbel commented 5 months ago

moreover, we need to make it in async way, like described was tiny described in this issue

0pdd commented 5 months ago

@h1alexbel the puzzle #125 is still not solved.

0pdd commented 5 months ago

@h1alexbel the puzzle #136 is still not solved; solved: #125.

h1alexbel commented 5 months ago

done