Skip to content

Commit 1949a8e

Browse files
authored
Add support for Github release webhook (#229)
* Add support for Github release webhook
1 parent b29a0d2 commit 1949a8e

18 files changed

+1541
-2
lines changed

scm/const.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ const (
4242
ActionMerge
4343
// issue comment
4444
ActionEdit
45+
// release
46+
ActionPublish
47+
ActionUnpublish
48+
ActionPrerelease
49+
ActionRelease
4550
)
4651

4752
// String returns the string representation of Action.
@@ -67,8 +72,14 @@ func (a Action) String() (s string) {
6772
return "synchronized"
6873
case ActionMerge:
6974
return "merged"
70-
case ActionEdit:
71-
return "edited"
75+
case ActionPublish:
76+
return "published"
77+
case ActionUnpublish:
78+
return "unpublished"
79+
case ActionPrerelease:
80+
return "prereleased"
81+
case ActionRelease:
82+
return "released"
7283
default:
7384
return
7485
}
@@ -108,6 +119,14 @@ func (a *Action) UnmarshalJSON(data []byte) error {
108119
*a = ActionMerge
109120
case "edited":
110121
*a = ActionEdit
122+
case "published":
123+
*a = ActionPublish
124+
case "unpublished":
125+
*a = ActionUnpublish
126+
case "prereleased":
127+
*a = ActionPrerelease
128+
case "released":
129+
*a = ActionRelease
111130
}
112131
return nil
113132
}
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
{
2+
"action": "created",
3+
"release": {
4+
"url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/releases/81372309",
5+
"assets_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/releases/81372309/assets",
6+
"upload_url": "https://uploads.github.com/repos/vcalasansh/harness-ngtriggers-test/releases/81372309/assets{?name,label}",
7+
"html_url": "https://github.com/vcalasansh/harness-ngtriggers-test/releases/tag/v1.0.0",
8+
"id": 81372309,
9+
"author": {
10+
"login": "vcalasansh",
11+
"id": 109106581,
12+
"node_id": "U_kgDOBoDVlQ",
13+
"avatar_url": "https://avatars.githubusercontent.com/u/109106581?v=4",
14+
"gravatar_id": "",
15+
"url": "https://api.github.com/users/vcalasansh",
16+
"html_url": "https://github.com/vcalasansh",
17+
"followers_url": "https://api.github.com/users/vcalasansh/followers",
18+
"following_url": "https://api.github.com/users/vcalasansh/following{/other_user}",
19+
"gists_url": "https://api.github.com/users/vcalasansh/gists{/gist_id}",
20+
"starred_url": "https://api.github.com/users/vcalasansh/starred{/owner}{/repo}",
21+
"subscriptions_url": "https://api.github.com/users/vcalasansh/subscriptions",
22+
"organizations_url": "https://api.github.com/users/vcalasansh/orgs",
23+
"repos_url": "https://api.github.com/users/vcalasansh/repos",
24+
"events_url": "https://api.github.com/users/vcalasansh/events{/privacy}",
25+
"received_events_url": "https://api.github.com/users/vcalasansh/received_events",
26+
"type": "User",
27+
"site_admin": false
28+
},
29+
"node_id": "RE_kwDOH5utuc4E2aSV",
30+
"tag_name": "v1.0.0",
31+
"target_commitish": "test-branch",
32+
"name": "New release!",
33+
"draft": false,
34+
"prerelease": false,
35+
"created_at": "2022-10-28T13:03:11Z",
36+
"published_at": "2022-10-28T16:36:52Z",
37+
"assets": [
38+
39+
],
40+
"tarball_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/tarball/v1.0.0",
41+
"zipball_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/zipball/v1.0.0",
42+
"body": "New release!"
43+
},
44+
"repository": {
45+
"id": 530296249,
46+
"node_id": "R_kgDOH5utuQ",
47+
"name": "harness-ngtriggers-test",
48+
"full_name": "vcalasansh/harness-ngtriggers-test",
49+
"private": true,
50+
"owner": {
51+
"login": "vcalasansh",
52+
"id": 109106581,
53+
"node_id": "U_kgDOBoDVlQ",
54+
"avatar_url": "https://avatars.githubusercontent.com/u/109106581?v=4",
55+
"gravatar_id": "",
56+
"url": "https://api.github.com/users/vcalasansh",
57+
"html_url": "https://github.com/vcalasansh",
58+
"followers_url": "https://api.github.com/users/vcalasansh/followers",
59+
"following_url": "https://api.github.com/users/vcalasansh/following{/other_user}",
60+
"gists_url": "https://api.github.com/users/vcalasansh/gists{/gist_id}",
61+
"starred_url": "https://api.github.com/users/vcalasansh/starred{/owner}{/repo}",
62+
"subscriptions_url": "https://api.github.com/users/vcalasansh/subscriptions",
63+
"organizations_url": "https://api.github.com/users/vcalasansh/orgs",
64+
"repos_url": "https://api.github.com/users/vcalasansh/repos",
65+
"events_url": "https://api.github.com/users/vcalasansh/events{/privacy}",
66+
"received_events_url": "https://api.github.com/users/vcalasansh/received_events",
67+
"type": "User",
68+
"site_admin": false
69+
},
70+
"html_url": "https://github.com/vcalasansh/harness-ngtriggers-test",
71+
"description": null,
72+
"fork": false,
73+
"url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test",
74+
"forks_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/forks",
75+
"keys_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/keys{/key_id}",
76+
"collaborators_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/collaborators{/collaborator}",
77+
"teams_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/teams",
78+
"hooks_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/hooks",
79+
"issue_events_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/issues/events{/number}",
80+
"events_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/events",
81+
"assignees_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/assignees{/user}",
82+
"branches_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/branches{/branch}",
83+
"tags_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/tags",
84+
"blobs_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/git/blobs{/sha}",
85+
"git_tags_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/git/tags{/sha}",
86+
"git_refs_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/git/refs{/sha}",
87+
"trees_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/git/trees{/sha}",
88+
"statuses_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/statuses/{sha}",
89+
"languages_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/languages",
90+
"stargazers_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/stargazers",
91+
"contributors_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/contributors",
92+
"subscribers_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/subscribers",
93+
"subscription_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/subscription",
94+
"commits_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/commits{/sha}",
95+
"git_commits_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/git/commits{/sha}",
96+
"comments_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/comments{/number}",
97+
"issue_comment_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/issues/comments{/number}",
98+
"contents_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/contents/{+path}",
99+
"compare_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/compare/{base}...{head}",
100+
"merges_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/merges",
101+
"archive_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/{archive_format}{/ref}",
102+
"downloads_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/downloads",
103+
"issues_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/issues{/number}",
104+
"pulls_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/pulls{/number}",
105+
"milestones_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/milestones{/number}",
106+
"notifications_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/notifications{?since,all,participating}",
107+
"labels_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/labels{/name}",
108+
"releases_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/releases{/id}",
109+
"deployments_url": "https://api.github.com/repos/vcalasansh/harness-ngtriggers-test/deployments",
110+
"created_at": "2022-08-29T16:12:07Z",
111+
"updated_at": "2022-08-29T16:12:07Z",
112+
"pushed_at": "2022-10-28T16:36:27Z",
113+
"git_url": "git://github.com/vcalasansh/harness-ngtriggers-test.git",
114+
"ssh_url": "[email protected]:vcalasansh/harness-ngtriggers-test.git",
115+
"clone_url": "https://github.com/vcalasansh/harness-ngtriggers-test.git",
116+
"svn_url": "https://github.com/vcalasansh/harness-ngtriggers-test",
117+
"homepage": null,
118+
"size": 11,
119+
"stargazers_count": 0,
120+
"watchers_count": 0,
121+
"language": null,
122+
"has_issues": true,
123+
"has_projects": true,
124+
"has_downloads": true,
125+
"has_wiki": true,
126+
"has_pages": false,
127+
"forks_count": 0,
128+
"mirror_url": null,
129+
"archived": false,
130+
"disabled": false,
131+
"open_issues_count": 0,
132+
"license": null,
133+
"allow_forking": true,
134+
"is_template": false,
135+
"web_commit_signoff_required": false,
136+
"topics": [
137+
138+
],
139+
"forks": 0,
140+
"open_issues": 0,
141+
"watchers": 0,
142+
"default_branch": "test-branch"
143+
},
144+
"sender": {
145+
"login": "vcalasansh",
146+
"id": 109106581,
147+
"node_id": "U_kgDOBoDVlQ",
148+
"avatar_url": "https://avatars.githubusercontent.com/u/109106581?v=4",
149+
"gravatar_id": "",
150+
"url": "https://api.github.com/users/vcalasansh",
151+
"html_url": "https://github.com/vcalasansh",
152+
"followers_url": "https://api.github.com/users/vcalasansh/followers",
153+
"following_url": "https://api.github.com/users/vcalasansh/following{/other_user}",
154+
"gists_url": "https://api.github.com/users/vcalasansh/gists{/gist_id}",
155+
"starred_url": "https://api.github.com/users/vcalasansh/starred{/owner}{/repo}",
156+
"subscriptions_url": "https://api.github.com/users/vcalasansh/subscriptions",
157+
"organizations_url": "https://api.github.com/users/vcalasansh/orgs",
158+
"repos_url": "https://api.github.com/users/vcalasansh/repos",
159+
"events_url": "https://api.github.com/users/vcalasansh/events{/privacy}",
160+
"received_events_url": "https://api.github.com/users/vcalasansh/received_events",
161+
"type": "User",
162+
"site_admin": false
163+
}
164+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"Action": "created",
3+
"Release": {
4+
"ID": 81372309,
5+
"Title": "New release!",
6+
"Description": "New release!",
7+
"Link": "https://github.com/vcalasansh/harness-ngtriggers-test/releases/tag/v1.0.0",
8+
"Tag": "v1.0.0",
9+
"Commitish": "test-branch",
10+
"Draft": false,
11+
"Prerelease": false,
12+
"Created": "2022-10-28T13:03:11Z",
13+
"Published": "2022-10-28T16:36:52Z"
14+
},
15+
"Repo": {
16+
"ID": "530296249",
17+
"Namespace": "vcalasansh",
18+
"Name": "harness-ngtriggers-test",
19+
"Perm": null,
20+
"Branch": "test-branch",
21+
"Private": true,
22+
"Clone": "https://github.com/vcalasansh/harness-ngtriggers-test.git",
23+
"CloneSSH": "[email protected]:vcalasansh/harness-ngtriggers-test.git",
24+
"Link": "https://github.com/vcalasansh/harness-ngtriggers-test",
25+
"Created": "0001-01-01T00:00:00Z",
26+
"Updated": "0001-01-01T00:00:00Z"
27+
},
28+
"Sender": {
29+
"Login": "vcalasansh",
30+
"Name": "",
31+
"Email": "",
32+
"Avatar": "https://avatars.githubusercontent.com/u/109106581?v=4"
33+
}
34+
}

0 commit comments

Comments
 (0)