Github : How to list milestone updates for an issue - github

How to list for a specific ticket the current milestone and its precedent assigned ones if applicable (+ date of each milestone update) ? I checked in the github API (https://developer.github.com/v3/issues/#get-a-single-issue) and I can extract the current milestone but not the previous assigned ones (if they exist). Any idea ?
Thank you,

You can use the Issues Events API. To test this I went to a test issue and:
Added milestone new
Added milestone two
After using that endpoint to query the API I got three events, two with type milestoned and one demilestoned. The endpoint allows you to filter for those events specifically to remove noise on very active issues. Here is an example of the reply (with obfuscated data)
[
{
"id": 2193329921,
"url": "https://api.github.com/repos/myOrg/myRepo/issues/events/2193329921",
"actor": {
"login": "myuser",
"id": 1192590,
"node_id": "MDQ6VXNlcjExOTI1OTA=",
"gravatar_id": "",
"url": "https://api.github.com/users/myuser",
"html_url": "https://github.com/myuser",
"followers_url": "https://api.github.com/users/myuser/followers",
"following_url": "https://api.github.com/users/myuser/following{/other_user}",
"gists_url": "https://api.github.com/users/myuser/gists{/gist_id}",
"starred_url": "https://api.github.com/users/myuser/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/myuser/subscriptions",
"organizations_url": "https://api.github.com/users/myuser/orgs",
"repos_url": "https://api.github.com/users/myuser/repos",
"events_url": "https://api.github.com/users/myuser/events{/privacy}",
"received_events_url": "https://api.github.com/users/myuser/received_events",
"type": "User",
"site_admin": true
},
"event": "milestoned",
"commit_id": null,
"commit_url": null,
"created_at": "2019-03-11T09:42:00Z",
"milestone": {
"title": "new"
}
},
{
"id": 2193330104,
"url": "https://api.github.com/repos/myOrg/myRepo/issues/events/2193330104",
"actor": {
"login": "myuser",
"id": 1192590,
"url": "https://api.github.com/users/myuser",
"html_url": "https://github.com/myuser",
"followers_url": "https://api.github.com/users/myuser/followers",
"following_url": "https://api.github.com/users/myuser/following{/other_user}",
"gists_url": "https://api.github.com/users/myuser/gists{/gist_id}",
"starred_url": "https://api.github.com/users/myuser/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/myuser/subscriptions",
"organizations_url": "https://api.github.com/users/myuser/orgs",
"repos_url": "https://api.github.com/users/myuser/repos",
"events_url": "https://api.github.com/users/myuser/events{/privacy}",
"received_events_url": "https://api.github.com/users/myuser/received_events",
"type": "User",
"site_admin": true
},
"event": "demilestoned",
"commit_id": null,
"commit_url": null,
"created_at": "2019-03-11T09:42:04Z",
"milestone": {
"title": "new"
}
},
{
"id": 2193330105,
"url": "https://api.github.com/repos/myOrg/myRepo/issues/events/2193330105",
"actor": {
"login": "myuser",
"url": "https://api.github.com/users/myuser",
"html_url": "https://github.com/myuser",
"followers_url": "https://api.github.com/users/myuser/followers",
"following_url": "https://api.github.com/users/myuser/following{/other_user}",
"gists_url": "https://api.github.com/users/myuser/gists{/gist_id}",
"starred_url": "https://api.github.com/users/myuser/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/myuser/subscriptions",
"organizations_url": "https://api.github.com/users/myuser/orgs",
"repos_url": "https://api.github.com/users/myuser/repos",
"events_url": "https://api.github.com/users/myuser/events{/privacy}",
"received_events_url": "https://api.github.com/users/myuser/received_events",
"type": "User",
"site_admin": true
},
"event": "milestoned",
"commit_id": null,
"commit_url": null,
"created_at": "2019-03-11T09:42:04Z",
"milestone": {
"title": "second"
}
}
]

Related

Get the login of a user that issued a comment on GitHub actions

I am running a workflow on
on:
issue_comment:
types: [created]
I am trying to get the username of the comment's author but the sample below fails:
run: |
COMMENT_AUTHOR=${{ github.event.issue_comment.user.login }}
Any suggestions?
I made a test with this workflow generating the following workflow run after adding a comment to an ISSUE.
According to the Github context of this event (cf body below) it seems you can get the username of the comment's author by using the following Github context values:
${{ github.actor }}
${{ github.triggering_actor }}
${{ github.event.comment.user.login }}
Github context payload for the ISSUE comment created event:
(using the workflow reference shared above)
{
"token": "***",
"job": "job1",
"ref": "refs/heads/main",
"sha": "07292d692c3b40708984df7e2bb55237e4c99a14",
"repository": "GuillaumeFalourd/poc-github-actions",
"repository_owner": "GuillaumeFalourd",
"repository_owner_id": "22433243",
"repositoryUrl": "git://github.com/GuillaumeFalourd/poc-github-actions.git",
"run_id": "3355679821",
"run_number": "1",
"retention_days": "90",
"run_attempt": "1",
"artifact_cache_size_limit": "10",
"repository_visibility": "public",
"repository_id": "351877820",
"actor_id": "22433243",
"actor": "GuillaumeFalourd",
"triggering_actor": "GuillaumeFalourd",
"workflow": "Test 71",
"head_ref": "",
"base_ref": "",
"event_name": "issue_comment",
"event": {
"action": "created",
"comment": {
"author_association": "OWNER",
"body": "test",
"created_at": "2022-10-30T13:38:36Z",
"html_url": "https://github.com/GuillaumeFalourd/poc-github-actions/issues/18#issuecomment-1296261344",
"id": 1296261344,
"issue_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/18",
"node_id": "IC_kwDOFPk6vM5NQ2Dg",
"performed_via_github_app": null,
"reactions": {
"+1": 0,
"-1": 0,
"confused": 0,
"eyes": 0,
"heart": 0,
"hooray": 0,
"laugh": 0,
"rocket": 0,
"total_count": 0,
"url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/comments/1296261344/reactions"
},
"updated_at": "2022-10-30T13:38:36Z",
"url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/comments/1296261344",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/22433243?v=4",
"events_url": "https://api.github.com/users/GuillaumeFalourd/events{/privacy}",
"followers_url": "https://api.github.com/users/GuillaumeFalourd/followers",
"following_url": "https://api.github.com/users/GuillaumeFalourd/following{/other_user}",
"gists_url": "https://api.github.com/users/GuillaumeFalourd/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/GuillaumeFalourd",
"id": 22433243,
"login": "GuillaumeFalourd",
"node_id": "MDQ6VXNlcjIyNDMzMjQz",
"organizations_url": "https://api.github.com/users/GuillaumeFalourd/orgs",
"received_events_url": "https://api.github.com/users/GuillaumeFalourd/received_events",
"repos_url": "https://api.github.com/users/GuillaumeFalourd/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/GuillaumeFalourd/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/GuillaumeFalourd/subscriptions",
"type": "User",
"url": "https://api.github.com/users/GuillaumeFalourd"
}
},
"issue": {
"active_lock_reason": null,
"assignee": null,
"assignees": [],
"author_association": "OWNER",
"body": "To check github context on ISSUE",
"closed_at": null,
"comments": 3,
"comments_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/18/comments",
"created_at": "2021-07-16T14:41:41Z",
"events_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/18/events",
"html_url": "https://github.com/GuillaumeFalourd/poc-github-actions/issues/18",
"id": 946356527,
"labels": [],
"labels_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/18/labels{/name}",
"locked": false,
"milestone": null,
"node_id": "MDU6SXNzdWU5NDYzNTY1Mjc=",
"number": 18,
"performed_via_github_app": null,
"reactions": {
"+1": 0,
"-1": 0,
"confused": 0,
"eyes": 0,
"heart": 0,
"hooray": 0,
"laugh": 0,
"rocket": 0,
"total_count": 0,
"url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/18/reactions"
},
"repository_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions",
"state": "open",
"state_reason": null,
"timeline_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/18/timeline",
"title": "[TEST] Github Context",
"updated_at": "2022-10-30T13:38:36Z",
"url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/18",
"user": {
"avatar_url": "https://avatars.githubusercontent.com/u/22433243?v=4",
"events_url": "https://api.github.com/users/GuillaumeFalourd/events{/privacy}",
"followers_url": "https://api.github.com/users/GuillaumeFalourd/followers",
"following_url": "https://api.github.com/users/GuillaumeFalourd/following{/other_user}",
"gists_url": "https://api.github.com/users/GuillaumeFalourd/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/GuillaumeFalourd",
"id": 22433243,
"login": "GuillaumeFalourd",
"node_id": "MDQ6VXNlcjIyNDMzMjQz",
"organizations_url": "https://api.github.com/users/GuillaumeFalourd/orgs",
"received_events_url": "https://api.github.com/users/GuillaumeFalourd/received_events",
"repos_url": "https://api.github.com/users/GuillaumeFalourd/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/GuillaumeFalourd/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/GuillaumeFalourd/subscriptions",
"type": "User",
"url": "https://api.github.com/users/GuillaumeFalourd"
}
},
"repository": {
"allow_forking": true,
"archive_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/assignees{/user}",
"blobs_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/branches{/branch}",
"clone_url": "https://github.com/GuillaumeFalourd/poc-github-actions.git",
"collaborators_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/comments{/number}",
"commits_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/commits{/sha}",
"compare_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/contents/{+path}",
"contributors_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/contributors",
"created_at": "2021-03-26T18:31:28Z",
"default_branch": "main",
"deployments_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/deployments",
"description": "Various proofs of concept examples using Github Actions 🤖",
"disabled": false,
"downloads_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/downloads",
"events_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/events",
"fork": false,
"forks": 34,
"forks_count": 34,
"forks_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/forks",
"full_name": "GuillaumeFalourd/poc-github-actions",
"git_commits_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/git/tags{/sha}",
"git_url": "git://github.com/GuillaumeFalourd/poc-github-actions.git",
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": true,
"homepage": "",
"hooks_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/hooks",
"html_url": "https://github.com/GuillaumeFalourd/poc-github-actions",
"id": 351877820,
"is_template": false,
"issue_comment_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues/events{/number}",
"issues_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/issues{/number}",
"keys_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/keys{/key_id}",
"labels_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/labels{/name}",
"language": "Python",
"languages_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/languages",
"license": {
"key": "apache-2.0",
"name": "Apache License 2.0",
"node_id": "MDc6TGljZW5zZTI=",
"spdx_id": "Apache-2.0",
"url": "https://api.github.com/licenses/apache-2.0"
},
"merges_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/merges",
"milestones_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/milestones{/number}",
"mirror_url": null,
"name": "poc-github-actions",
"node_id": "MDEwOlJlcG9zaXRvcnkzNTE4Nzc4MjA=",
"notifications_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/notifications{?since,all,participating}",
"open_issues": 7,
"open_issues_count": 7,
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/22433243?v=4",
"events_url": "https://api.github.com/users/GuillaumeFalourd/events{/privacy}",
"followers_url": "https://api.github.com/users/GuillaumeFalourd/followers",
"following_url": "https://api.github.com/users/GuillaumeFalourd/following{/other_user}",
"gists_url": "https://api.github.com/users/GuillaumeFalourd/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/GuillaumeFalourd",
"id": 22433243,
"login": "GuillaumeFalourd",
"node_id": "MDQ6VXNlcjIyNDMzMjQz",
"organizations_url": "https://api.github.com/users/GuillaumeFalourd/orgs",
"received_events_url": "https://api.github.com/users/GuillaumeFalourd/received_events",
"repos_url": "https://api.github.com/users/GuillaumeFalourd/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/GuillaumeFalourd/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/GuillaumeFalourd/subscriptions",
"type": "User",
"url": "https://api.github.com/users/GuillaumeFalourd"
},
"private": false,
"pulls_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/pulls{/number}",
"pushed_at": "2022-10-30T13:37:51Z",
"releases_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/releases{/id}",
"size": 3239,
"ssh_url": "git#github.com:GuillaumeFalourd/poc-github-actions.git",
"stargazers_count": 71,
"stargazers_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/stargazers",
"statuses_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/subscribers",
"subscription_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/subscription",
"svn_url": "https://github.com/GuillaumeFalourd/poc-github-actions",
"tags_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/tags",
"teams_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/teams",
"topics": [
"beginners",
"examples",
"github-actions",
"poc",
"proof-of-concept",
"workflows"
],
"trees_url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions/git/trees{/sha}",
"updated_at": "2022-10-26T04:39:55Z",
"url": "https://api.github.com/repos/GuillaumeFalourd/poc-github-actions",
"visibility": "public",
"watchers": 71,
"watchers_count": 71,
"web_commit_signoff_required": false
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/22433243?v=4",
"events_url": "https://api.github.com/users/GuillaumeFalourd/events{/privacy}",
"followers_url": "https://api.github.com/users/GuillaumeFalourd/followers",
"following_url": "https://api.github.com/users/GuillaumeFalourd/following{/other_user}",
"gists_url": "https://api.github.com/users/GuillaumeFalourd/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/GuillaumeFalourd",
"id": 22433243,
"login": "GuillaumeFalourd",
"node_id": "MDQ6VXNlcjIyNDMzMjQz",
"organizations_url": "https://api.github.com/users/GuillaumeFalourd/orgs",
"received_events_url": "https://api.github.com/users/GuillaumeFalourd/received_events",
"repos_url": "https://api.github.com/users/GuillaumeFalourd/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/GuillaumeFalourd/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/GuillaumeFalourd/subscriptions",
"type": "User",
"url": "https://api.github.com/users/GuillaumeFalourd"
}
},
"server_url": "https://github.com",
"api_url": "https://api.github.com",
"graphql_url": "https://api.github.com/graphql",
"ref_name": "main",
"ref_protected": false,
"ref_type": "branch",
"secret_source": "Actions",
"workspace": "/home/runner/work/poc-github-actions/poc-github-actions",
"action": "__run"
}

Can't find format for creating SHA256 from GitHub webhook response

I have a web hook in my GitHub repo that is triggered every time there is a push event. Let's say the push event JSON looks like this as an example:
{
"ref": "refs/heads/develop"
"repository": {
"id": 123456789,
"name": "SweetSweetRepo"
}
}
I provided a secret to the GitHub webhook and GitHub tells me in the request headers web hook UI that it created a SHA256 of abc123456 (for example).
I'm trying to create a proxy for the webhook but I cannot create this SHA on my own! I know my SHA function works because I tested it on example strings like 'hello world' and checked them vs. online converters. But I don't understand how I'm supposed to strip, escape, stringify, or otherwise format that GitHub JSON payload so it gives me the desired SHA.
UPDATE:
Here is a full example. I created a new repo. Here is a link to the web hook so you can see for yourself. https://github.com/fbomb111/webhook-test/settings/hooks/294937131
Here are the GitHub headers:
Request URL: http://example.com:
Request method: POST
Accept: */*
content-type: application/json
User-Agent: GitHub-Hookshot/5465ee1
X-GitHub-Delivery: 4ae55e0e-a9d6-11eb-87d7-8f44c61441ec
X-GitHub-Event: push
X-GitHub-Hook-ID: 294937131
X-GitHub-Hook-Installation-Target-ID: 363207517
X-GitHub-Hook-Installation-Target-Type: repository
X-Hub-Signature: sha1=9c62a9ab96bfe7a0f9b0b511dd9346a8f5ad7e69
X-Hub-Signature-256: sha256=aaaa0a8550aba58490572b65f998950a242ac61e20f2e295f1c839f58e6b3a23
Here is the payload:
{
"ref": "refs/heads/main",
"before": "0000000000000000000000000000000000000000",
"after": "3f07cfffce2cf13559f33f11561dc8ec139a33a9",
"repository": {
"id": 363207517,
"node_id": "MDEwOlJlcG9zaXRvcnkzNjMyMDc1MTc=",
"name": "webhook-test",
"full_name": "me/webhook-test",
"private": false,
"owner": {
"name": "me",
"email": "me#gmail.com",
"login": "me",
"id": 482183,
"node_id": "MDQ6VXNlcjQ4MjE4Mw==",
"avatar_url": "https://avatars.githubusercontent.com/u/482183?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/me",
"html_url": "https://github.com/me",
"followers_url": "https://api.github.com/users/me/followers",
"following_url": "https://api.github.com/users/me/following{/other_user}",
"gists_url": "https://api.github.com/users/me/gists{/gist_id}",
"starred_url": "https://api.github.com/users/me/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/me/subscriptions",
"organizations_url": "https://api.github.com/users/me/orgs",
"repos_url": "https://api.github.com/users/me/repos",
"events_url": "https://api.github.com/users/me/events{/privacy}",
"received_events_url": "https://api.github.com/users/me/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/me/webhook-test",
"description": null,
"fork": false,
"url": "https://github.com/me/webhook-test",
"forks_url": "https://api.github.com/repos/me/webhook-test/forks",
"keys_url": "https://api.github.com/repos/me/webhook-test/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/me/webhook-test/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/me/webhook-test/teams",
"hooks_url": "https://api.github.com/repos/me/webhook-test/hooks",
"issue_events_url": "https://api.github.com/repos/me/webhook-test/issues/events{/number}",
"events_url": "https://api.github.com/repos/me/webhook-test/events",
"assignees_url": "https://api.github.com/repos/me/webhook-test/assignees{/user}",
"branches_url": "https://api.github.com/repos/me/webhook-test/branches{/branch}",
"tags_url": "https://api.github.com/repos/me/webhook-test/tags",
"blobs_url": "https://api.github.com/repos/me/webhook-test/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/me/webhook-test/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/me/webhook-test/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/me/webhook-test/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/me/webhook-test/statuses/{sha}",
"languages_url": "https://api.github.com/repos/me/webhook-test/languages",
"stargazers_url": "https://api.github.com/repos/me/webhook-test/stargazers",
"contributors_url": "https://api.github.com/repos/me/webhook-test/contributors",
"subscribers_url": "https://api.github.com/repos/me/webhook-test/subscribers",
"subscription_url": "https://api.github.com/repos/me/webhook-test/subscription",
"commits_url": "https://api.github.com/repos/me/webhook-test/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/me/webhook-test/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/me/webhook-test/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/me/webhook-test/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/me/webhook-test/contents/{+path}",
"compare_url": "https://api.github.com/repos/me/webhook-test/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/me/webhook-test/merges",
"archive_url": "https://api.github.com/repos/me/webhook-test/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/me/webhook-test/downloads",
"issues_url": "https://api.github.com/repos/me/webhook-test/issues{/number}",
"pulls_url": "https://api.github.com/repos/me/webhook-test/pulls{/number}",
"milestones_url": "https://api.github.com/repos/me/webhook-test/milestones{/number}",
"notifications_url": "https://api.github.com/repos/me/webhook-test/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/me/webhook-test/labels{/name}",
"releases_url": "https://api.github.com/repos/me/webhook-test/releases{/id}",
"deployments_url": "https://api.github.com/repos/me/webhook-test/deployments",
"created_at": 1619802247,
"updated_at": "2021-04-30T17:04:07Z",
"pushed_at": 1619802340,
"git_url": "git://github.com/me/webhook-test.git",
"ssh_url": "git#github.com: me/webhook-test.git",
"clone_url": "https://github.com/me/webhook-test.git",
"svn_url": "https://github.com/me/webhook-test",
"homepage": null,
"size": 0,
"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": 0,
"license": null,
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main",
"stargazers": 0,
"master_branch": "main"
},
"pusher": {
"name": "me",
"email": "me#gmail.com"
},
"sender": {
"login": "me",
"id": 482183,
"node_id": "MDQ6VXNlcjQ4MjE4Mw==",
"avatar_url": "https://avatars.githubusercontent.com/u/482183?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/me",
"html_url": "https://github.com/me",
"followers_url": "https://api.github.com/users/me/followers",
"following_url": "https://api.github.com/users/me/following{/other_user}",
"gists_url": "https://api.github.com/users/me/gists{/gist_id}",
"starred_url": "https://api.github.com/users/me/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/me/subscriptions",
"organizations_url": "https://api.github.com/users/me/orgs",
"repos_url": "https://api.github.com/users/me/repos",
"events_url": "https://api.github.com/users/me/events{/privacy}",
"received_events_url": "https://api.github.com/users/me/received_events",
"type": "User",
"site_admin": false
},
"created": true,
"deleted": false,
"forced": false,
"base_ref": null,
"compare": "https://github.com/me/webhook-test/commit/3f07cfffce2c",
"commits": [
{
"id": "3f07cfffce2cf13559f33f11561dc8ec139a33a9",
"tree_id": "782748b547b6e62d246487abfa7210775795d58f",
"distinct": true,
"message": "Create Readme.md",
"timestamp": "2021-04-30T13:05:40-04:00",
"url": "https://github.com/me/webhook-test/commit/3f07cfffce2cf13559f33f11561dc8ec139a33a9",
"author": {
"name": "me",
"email": "me",
"username": "me"
},
"committer": {
"name": "GitHub",
"email": "noreply#github.com",
"username": "web-flow"
},
"added": [
"Readme.md"
],
"removed": [
],
"modified": [
]
}
],
"head_commit": {
"id": "3f07cfffce2cf13559f33f11561dc8ec139a33a9",
"tree_id": "782748b547b6e62d246487abfa7210775795d58f",
"distinct": true,
"message": "Create Readme.md",
"timestamp": "2021-04-30T13:05:40-04:00",
"url": "https://github.com/me/webhook-test/commit/3f07cfffce2cf13559f33f11561dc8ec139a33a9",
"author": {
"name": "me",
"email": "me",
"username": "me"
},
"committer": {
"name": "GitHub",
"email": "noreply#github.com",
"username": "web-flow"
},
"added": [
"Readme.md"
],
"removed": [
],
"modified": [
]
}
}
Here is the secret 1234567890
Note the sha value in the header: X-Hub-Signature-256: sha256=aaaa0a8550aba58490572b65f998950a242ac61e20f2e295f1c839f58e6b3a23
Now go to a online converter such as this https://dinochiesa.github.io/hmachash/index.html
Use the exact same payload and secret. You won't get the same sha256 value.
My guess is because GitHub is using something other than pretty-printed json to do the sha calculation. But I've tried many variations of what that formatting might be without luck.

Invalid Json returned by Taiga webhook in Github, but it seems valid?

I am trying to set up a webhook between Taiga and Github, the payloadis below, but the response I get is:
{"_error_message": "The payload is not a valid json", "_error_type": "taiga.base.exceptions.BadRequest"}
Here is the payload:
{
"zen": "Avoid administrative distraction.",
"hook_id": 58924287,
"hook": {
"type": "Repository",
"id": 58924287,
"name": "web",
"active": true,
"events": [
"*"
],
"config": {
"content_type": "form",
"insecure_ssl": "0",
"secret": "********",
"url": "https://api.taiga.io/api/v1/github-hook?project=291735"
},
"updated_at": "2018-10-24T23:40:03Z",
"created_at": "2018-10-24T23:40:03Z",
"url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks/58924287",
"test_url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks/58924287/test",
"ping_url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks/58924287/pings",
"last_response": {
"code": null,
"status": "unused",
"message": null
}
},
"repository": {
"id": 154575276,
"node_id": "MDEwOlJlcG9zaXRvcnkxNTQ1NzUyNzY=",
"name": "multivaria",
"full_name": "AncientSwordRage/multivaria",
"private": false,
"owner": {
"login": "AncientSwordRage",
"id": 5961746,
"node_id": "MDQ6VXNlcjU5NjE3NDY=",
"avatar_url": "https://avatars3.githubusercontent.com/u/5961746?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/AncientSwordRage",
"html_url": "https://github.com/AncientSwordRage",
"followers_url": "https://api.github.com/users/AncientSwordRage/followers",
"following_url": "https://api.github.com/users/AncientSwordRage/following{/other_user}",
"gists_url": "https://api.github.com/users/AncientSwordRage/gists{/gist_id}",
"starred_url": "https://api.github.com/users/AncientSwordRage/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/AncientSwordRage/subscriptions",
"organizations_url": "https://api.github.com/users/AncientSwordRage/orgs",
"repos_url": "https://api.github.com/users/AncientSwordRage/repos",
"events_url": "https://api.github.com/users/AncientSwordRage/events{/privacy}",
"received_events_url": "https://api.github.com/users/AncientSwordRage/received_events",
"type": "User",
"site_admin": false
},
"html_url": "https://github.com/AncientSwordRage/multivaria",
"description": "Multivariate Hypergeometric Probabilities (In Space!)",
"fork": false,
"url": "https://api.github.com/repos/AncientSwordRage/multivaria",
"forks_url": "https://api.github.com/repos/AncientSwordRage/multivaria/forks",
"keys_url": "https://api.github.com/repos/AncientSwordRage/multivaria/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/AncientSwordRage/multivaria/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/AncientSwordRage/multivaria/teams",
"hooks_url": "https://api.github.com/repos/AncientSwordRage/multivaria/hooks",
"issue_events_url": "https://api.github.com/repos/AncientSwordRage/multivaria/issues/events{/number}",
"events_url": "https://api.github.com/repos/AncientSwordRage/multivaria/events",
"assignees_url": "https://api.github.com/repos/AncientSwordRage/multivaria/assignees{/user}",
"branches_url": "https://api.github.com/repos/AncientSwordRage/multivaria/branches{/branch}",
"tags_url": "https://api.github.com/repos/AncientSwordRage/multivaria/tags",
"blobs_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/AncientSwordRage/multivaria/statuses/{sha}",
"languages_url": "https://api.github.com/repos/AncientSwordRage/multivaria/languages",
"stargazers_url": "https://api.github.com/repos/AncientSwordRage/multivaria/stargazers",
"contributors_url": "https://api.github.com/repos/AncientSwordRage/multivaria/contributors",
"subscribers_url": "https://api.github.com/repos/AncientSwordRage/multivaria/subscribers",
"subscription_url": "https://api.github.com/repos/AncientSwordRage/multivaria/subscription",
"commits_url": "https://api.github.com/repos/AncientSwordRage/multivaria/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/AncientSwordRage/multivaria/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/AncientSwordRage/multivaria/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/AncientSwordRage/multivaria/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/AncientSwordRage/multivaria/contents/{+path}",
"compare_url": "https://api.github.com/repos/AncientSwordRage/multivaria/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/AncientSwordRage/multivaria/merges",
"archive_url": "https://api.github.com/repos/AncientSwordRage/multivaria/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/AncientSwordRage/multivaria/downloads",
"issues_url": "https://api.github.com/repos/AncientSwordRage/multivaria/issues{/number}",
"pulls_url": "https://api.github.com/repos/AncientSwordRage/multivaria/pulls{/number}",
"milestones_url": "https://api.github.com/repos/AncientSwordRage/multivaria/milestones{/number}",
"notifications_url": "https://api.github.com/repos/AncientSwordRage/multivaria/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/AncientSwordRage/multivaria/labels{/name}",
"releases_url": "https://api.github.com/repos/AncientSwordRage/multivaria/releases{/id}",
"deployments_url": "https://api.github.com/repos/AncientSwordRage/multivaria/deployments",
"created_at": "2018-10-24T22:07:31Z",
"updated_at": "2018-10-24T23:00:16Z",
"pushed_at": "2018-10-24T23:00:14Z",
"git_url": "git://github.com/AncientSwordRage/multivaria.git",
"ssh_url": "git#github.com:AncientSwordRage/multivaria.git",
"clone_url": "https://github.com/AncientSwordRage/multivaria.git",
"svn_url": "https://github.com/AncientSwordRage/multivaria",
"homepage": null,
"size": 154,
"stargazers_count": 0,
"watchers_count": 0,
"language": "JavaScript",
"has_issues": true,
"has_projects": true,
"has_downloads": true,
"has_wiki": true,
"has_pages": false,
"forks_count": 0,
"mirror_url": null,
"archived": false,
"open_issues_count": 0,
"license": {
"key": "gpl-3.0",
"name": "GNU General Public License v3.0",
"spdx_id": "GPL-3.0",
"url": "https://api.github.com/licenses/gpl-3.0",
"node_id": "MDc6TGljZW5zZTk="
},
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "master"
},
"sender": {
"login": "AncientSwordRage",
"id": 5961746,
"node_id": "MDQ6VXNlcjU5NjE3NDY=",
"avatar_url": "https://avatars3.githubusercontent.com/u/5961746?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/AncientSwordRage",
"html_url": "https://github.com/AncientSwordRage",
"followers_url": "https://api.github.com/users/AncientSwordRage/followers",
"following_url": "https://api.github.com/users/AncientSwordRage/following{/other_user}",
"gists_url": "https://api.github.com/users/AncientSwordRage/gists{/gist_id}",
"starred_url": "https://api.github.com/users/AncientSwordRage/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/AncientSwordRage/subscriptions",
"organizations_url": "https://api.github.com/users/AncientSwordRage/orgs",
"repos_url": "https://api.github.com/users/AncientSwordRage/repos",
"events_url": "https://api.github.com/users/AncientSwordRage/events{/privacy}",
"received_events_url": "https://api.github.com/users/AncientSwordRage/received_events",
"type": "User",
"site_admin": false
}
}
(I don't think there's anything secret there)
Why does Taiga report this is invalid (I've checked - it's not)?
On the github side, check how the content-type is configured for your hook.
It looks like it is Form-Url-encoded (in the payload you show :
...
"content_type": "form".
...
)
Ensure that it is configured as application/json, as expected by taiga.
And yes, when you look at the payload on the github side, it displays it as JSON even when sent as Form.

How to display JSON hash content using rails

Hello I'm new to ruby rails and I'm trying to hardcode to display into my browser the "searched_count" from the phrase "java" from my json hash that I got using an url, which is the following
{
"results": [
{
"_class": "search_log",
"id": 88,
"phrase": "java",
"searched_count": 3758269,
"url": "/courses/search/?q=java"
},
{
"_class": "search_log",
"id": 296,
"phrase": "javascript",
"searched_count": 2385833,
"url": "/courses/search/?q=javascript"
},
{
"_class": "search_log",
"id": 642,
"phrase": "java programming",
"searched_count": 371310,
"url": "/courses/search/?q=java+programming"
},
{
"_class": "search_log",
"id": 6192,
"phrase": "java for complete beginners",
"searched_count": 193568,
"url": "/courses/search/?q=java+for+complete+beginners"
},
{
"_class": "course",
"id": 478878,
"title": "Java Maven: Introduccion paso a paso para no expertos",
"url": "/java-maven/",
"type_label": "curso"
},
{
"_class": "course",
"id": 1325394,
"title": "Java a Profundidad - Temas Avanzados y Desarrollo Web.",
"url": "/java-a-profundidad/",
"type_label": "curso"
},
{
"_class": "course",
"id": 1187500,
"title": "Java EE 7 & Frameworks - JSF2, Spring 4, Struts 2 y EJB3",
"url": "/java-ee-7-frameworks-jsf2-spring-4-struts-2-y-ejb3/",
"type_label": "curso"
},
{
"_class": "course",
"id": 490376,
"title": "Java para Administradores de Sistemas",
"url": "/java-sysadmin/",
"type_label": "curso"
},
{
"_class": "user",
"id": 28097854,
"title": "Javascript Lab",
"name": "Javascript",
"display_name": "Javascript Lab",
"url": "/user/javascript-lab/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 17677946,
"title": "Lara Javalyn",
"name": "Lara",
"display_name": "Lara Javalyn",
"url": "/user/lara-javalyn/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 7708594,
"title": "Ashay Javadekar",
"name": "Ashay",
"display_name": "Ashay Javadekar",
"url": "/user/ashayjavadekar/",
"type_label": "instructor"
},
{
"_class": "user",
"id": 23997368,
"title": "Alex Javad",
"name": "Alex",
"display_name": "Alex Javad",
"url": "/user/alex-javad-2/",
"type_label": "instructor"
}
]
}
I have two methods to try to accomplish this:
require 'sinatra'
require 'net/http'
require 'json'
require 'openssl'
OpenSSL::SSL::VERIFY_PEER = OpenSSL::SSL::VERIFY_NONE
def get_search_count(term)
url = 'https://www.udemy.com/api-2.0/search-suggestions?q=java'
uri = URI(url)
response = Net::HTTP.get(uri)
return JSON.parse(response)
end
get '/' do
#result = get_search_count "java"
#searchedCount = #result["results"][0]["searched_count"]
"Searched count: #{#searched_count}"
end
When I load my localhost all I get is the phrase "Searched count:" with nothing following, any help identifying my mistakes is greatly appreciated thanks in advance!
You have a typo in the string. You're reading #searched_count rather than #searchedCount

How to find users who approved a pull request using github api?

For example, given this pull request : https://github.com/harsh-groverfk/jenkins-demo/pull/16
How to find the list of users who have "approved" the changes in these pull requests.
this is an example review for this pull request : https://github.com/harsh-groverfk/jenkins-demo/pull/16#pullrequestreview-16967726
You can do this by using the List Reviews for a Pull Request API endpoint. For the example PR you've listed this would be:
GET /repos/harsh-groverfk/jenkins-demo/pulls/16/reviews
This will output all reviews done on a PR (example from the docs):
[
{
"id": 80,
"user": {
"login": "octocat",
"id": 1,
"avatar_url": "https://github.com/images/error/octocat_happy.gif",
"gravatar_id": "",
"url": "https://api.github.com/users/octocat",
"html_url": "https://github.com/octocat",
"followers_url": "https://api.github.com/users/octocat/followers",
"following_url": "https://api.github.com/users/octocat/following{/other_user}",
"gists_url": "https://api.github.com/users/octocat/gists{/gist_id}",
"starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/octocat/subscriptions",
"organizations_url": "https://api.github.com/users/octocat/orgs",
"repos_url": "https://api.github.com/users/octocat/repos",
"events_url": "https://api.github.com/users/octocat/events{/privacy}",
"received_events_url": "https://api.github.com/users/octocat/received_events",
"type": "User",
"site_admin": false
},
"body": "Here is the body for the review.",
"commit_id": "ecdd80bb57125d7ba9641ffaa4d7d2c19d3f3091",
"state": "APPROVED",
"html_url": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80",
"pull_request_url": "https://api.github.com/repos/octocat/Hello-World/pulls/12",
"_links": {
"html": {
"href": "https://github.com/octocat/Hello-World/pull/12#pullrequestreview-80"
},
"pull_request": {
"href": "https://api.github.com/repos/octocat/Hello-World/pulls/12"
}
}
}
]
Using the GraphQL API:
{
repository(name: "jenkins-demo", owner: "harsh-groverfk") {
pullRequest(number: 16) {
reviews(first: 100, states: APPROVED) {
nodes {
author {
avatarUrl
login
resourcePath
url
}
}
}
}
}
}
Response:
{
"data": {
"repository": {
"pullRequest": {
"reviews": {
"nodes": [
{
"author": {
"avatarUrl": "https://avatars.githubusercontent.com/u/24560176?v=4",
"login": "alekh2",
"resourcePath": "/alekh2",
"url": "https://github.com/alekh2"
}
}
]
}
}
}
}
}
If you don't have the specific pull request number, you can query the pullRequests field.