Open7
GitHub の Release Event を監視したい (不審な Release Event を検出したい)
Release に関する Event は様々あるが、結構難しい
検出したいイベントはこれ
- release is created
- release is deleted
- prelease or draft are changed to release
- release is changed to prerelease
これに対し、 event type はこれ
- created: A draft was saved, or a release or pre-release was published without previously being saved as a draft.
- deleted: A release, pre-release, or draft release was deleted.
- edited: The details of a release, pre-release, or draft release were edited. https://docs.github.com/repositories/releasing-projects-on-github/managing-releases-in-a-repository#editing-a-release
- prereleased: A release was created and identified as a pre-release. A pre-release is a release that is not ready for production and may be unstable.
- published: A release, pre-release, or draft of a release was published.
- released: A release was published, or a pre-release was changed to a release.
- unpublished: A release or pre-release was unpublished.
| requirement | created | deleted | edited | prereleased | published | released | unpublished |
|---|---|---|---|---|---|---|---|
| release is created | o | x | x | x | o | o | x |
| release is deleted | x | o | x | x | x | x | x |
| prelease or draft are changed to release | x | x | x | x | x | o | x |
| release is changed to prerelease | x | x | x | x | x |
payload
{
"token": "***",
"job": "notify-release-creation",
"ref": "refs/tags/v0.5.3-2",
"sha": "63e95e9c489a6205005f0ab4ae5494c4e5b97093",
"repository": "suzuki-shunsuke/test-github-action",
"repository_owner": "suzuki-shunsuke",
"repository_owner_id": "13323303",
"repositoryUrl": "git://github.com/suzuki-shunsuke/test-github-action.git",
"run_id": "3925634243",
"run_number": "6",
"retention_days": "90",
"run_attempt": "1",
"artifact_cache_size_limit": "10",
"repository_visibility": "public",
"repository_id": "221882701",
"actor_id": "13323303",
"actor": "suzuki-shunsuke",
"triggering_actor": "suzuki-shunsuke",
"workflow": "Notify release Creation",
"head_ref": "",
"base_ref": "",
"event_name": "release",
"event": {
"action": "created",
"release": {
"assets": [],
"assets_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/releases/89067708/assets",
"author": {
"avatar_url": "https://avatars.githubusercontent.com/u/13323303?v=4",
"events_url": "https://api.github.com/users/suzuki-shunsuke/events{/privacy}",
"followers_url": "https://api.github.com/users/suzuki-shunsuke/followers",
"following_url": "https://api.github.com/users/suzuki-shunsuke/following{/other_user}",
"gists_url": "https://api.github.com/users/suzuki-shunsuke/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/suzuki-shunsuke",
"id": 13323303,
"login": "suzuki-shunsuke",
"node_id": "MDQ6VXNlcjEzMzIzMzAz",
"organizations_url": "https://api.github.com/users/suzuki-shunsuke/orgs",
"received_events_url": "https://api.github.com/users/suzuki-shunsuke/received_events",
"repos_url": "https://api.github.com/users/suzuki-shunsuke/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/suzuki-shunsuke/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/suzuki-shunsuke/subscriptions",
"type": "User",
"url": "https://api.github.com/users/suzuki-shunsuke"
},
"body": "",
"created_at": "2023-01-15T22:39:00Z",
"draft": false,
"html_url": "https://github.com/suzuki-shunsuke/test-github-action/releases/tag/v0.5.3-2",
"id": 89067708,
"name": "",
"node_id": "RE_kwDODTmpTc4FTxC8",
"prerelease": true,
"published_at": "2023-01-15T22:39:17Z",
"tag_name": "v0.5.3-2",
"tarball_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/tarball/v0.5.3-2",
"target_commitish": "main",
"upload_url": "https://uploads.github.com/repos/suzuki-shunsuke/test-github-action/releases/89067708/assets{?name,label}",
"url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/releases/89067708",
"zipball_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/zipball/v0.5.3-2"
},
"repository": {
"allow_forking": true,
"archive_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/{archive_format}{/ref}",
"archived": false,
"assignees_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/assignees{/user}",
"blobs_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/git/blobs{/sha}",
"branches_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/branches{/branch}",
"clone_url": "https://github.com/suzuki-shunsuke/test-github-action.git",
"collaborators_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/collaborators{/collaborator}",
"comments_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/comments{/number}",
"commits_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/commits{/sha}",
"compare_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/compare/{base}...{head}",
"contents_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/contents/{+path}",
"contributors_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/contributors",
"created_at": "2019-11-15T08:48:53Z",
"default_branch": "main",
"deployments_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/deployments",
"description": null,
"disabled": false,
"downloads_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/downloads",
"events_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/events",
"fork": false,
"forks": 1,
"forks_count": 1,
"forks_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/forks",
"full_name": "suzuki-shunsuke/test-github-action",
"git_commits_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/git/commits{/sha}",
"git_refs_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/git/refs{/sha}",
"git_tags_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/git/tags{/sha}",
"git_url": "git://github.com/suzuki-shunsuke/test-github-action.git",
"has_discussions": true,
"has_downloads": true,
"has_issues": true,
"has_pages": false,
"has_projects": true,
"has_wiki": false,
"homepage": null,
"hooks_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/hooks",
"html_url": "https://github.com/suzuki-shunsuke/test-github-action",
"id": 221882701,
"is_template": false,
"issue_comment_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/issues/comments{/number}",
"issue_events_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/issues/events{/number}",
"issues_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/issues{/number}",
"keys_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/keys{/key_id}",
"labels_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/labels{/name}",
"language": null,
"languages_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/languages",
"license": {
"key": "mit",
"name": "MIT License",
"node_id": "MDc6TGljZW5zZTEz",
"spdx_id": "MIT",
"url": "https://api.github.com/licenses/mit"
},
"merges_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/merges",
"milestones_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/milestones{/number}",
"mirror_url": null,
"name": "test-github-action",
"node_id": "MDEwOlJlcG9zaXRvcnkyMjE4ODI3MDE=",
"notifications_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/notifications{?since,all,participating}",
"open_issues": 53,
"open_issues_count": 53,
"owner": {
"avatar_url": "https://avatars.githubusercontent.com/u/13323303?v=4",
"events_url": "https://api.github.com/users/suzuki-shunsuke/events{/privacy}",
"followers_url": "https://api.github.com/users/suzuki-shunsuke/followers",
"following_url": "https://api.github.com/users/suzuki-shunsuke/following{/other_user}",
"gists_url": "https://api.github.com/users/suzuki-shunsuke/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/suzuki-shunsuke",
"id": 13323303,
"login": "suzuki-shunsuke",
"node_id": "MDQ6VXNlcjEzMzIzMzAz",
"organizations_url": "https://api.github.com/users/suzuki-shunsuke/orgs",
"received_events_url": "https://api.github.com/users/suzuki-shunsuke/received_events",
"repos_url": "https://api.github.com/users/suzuki-shunsuke/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/suzuki-shunsuke/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/suzuki-shunsuke/subscriptions",
"type": "User",
"url": "https://api.github.com/users/suzuki-shunsuke"
},
"private": false,
"pulls_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/pulls{/number}",
"pushed_at": "2023-01-15T22:39:01Z",
"releases_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/releases{/id}",
"size": 278,
"ssh_url": "git@github.com:suzuki-shunsuke/test-github-action.git",
"stargazers_count": 1,
"stargazers_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/stargazers",
"statuses_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/statuses/{sha}",
"subscribers_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/subscribers",
"subscription_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/subscription",
"svn_url": "https://github.com/suzuki-shunsuke/test-github-action",
"tags_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/tags",
"teams_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/teams",
"topics": [],
"trees_url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action/git/trees{/sha}",
"updated_at": "2022-12-14T23:08:08Z",
"url": "https://api.github.com/repos/suzuki-shunsuke/test-github-action",
"visibility": "public",
"watchers": 1,
"watchers_count": 1,
"web_commit_signoff_required": false
},
"sender": {
"avatar_url": "https://avatars.githubusercontent.com/u/13323303?v=4",
"events_url": "https://api.github.com/users/suzuki-shunsuke/events{/privacy}",
"followers_url": "https://api.github.com/users/suzuki-shunsuke/followers",
"following_url": "https://api.github.com/users/suzuki-shunsuke/following{/other_user}",
"gists_url": "https://api.github.com/users/suzuki-shunsuke/gists{/gist_id}",
"gravatar_id": "",
"html_url": "https://github.com/suzuki-shunsuke",
"id": 13323303,
"login": "suzuki-shunsuke",
"node_id": "MDQ6VXNlcjEzMzIzMzAz",
"organizations_url": "https://api.github.com/users/suzuki-shunsuke/orgs",
"received_events_url": "https://api.github.com/users/suzuki-shunsuke/received_events",
"repos_url": "https://api.github.com/users/suzuki-shunsuke/repos",
"site_admin": false,
"starred_url": "https://api.github.com/users/suzuki-shunsuke/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/suzuki-shunsuke/subscriptions",
"type": "User",
"url": "https://api.github.com/users/suzuki-shunsuke"
}
},
"server_url": "https://github.com",
"api_url": "https://api.github.com",
"graphql_url": "https://api.github.com/graphql",
"ref_name": "v0.5.3-2",
"ref_protected": false,
"ref_type": "tag",
"secret_source": "Actions",
"workflow_ref": "suzuki-shunsuke/test-github-action/.github/workflows/create-release.yaml@refs/tags/v0.5.3-2",
"workflow_sha": "63e95e9c489a6205005f0ab4ae5494c4e5b97093",
"workspace": "/home/runner/work/test-github-action/test-github-action",
"action": "__run"
}
| requirement | created | deleted | edited | prereleased | published | released | unpublished |
|---|---|---|---|---|---|---|---|
| release 作成 | o | o | o | ||||
| prerelease 作成 | o | o | o | ||||
| draft 生成 | |||||||
| prerelease => release | o | ||||||
| draft => release | o | o | |||||
| draft => prerelease | o | ||||||
| release => prerelease | o | ||||||
| draft 削除 | |||||||
| prerelease 削除 | o | ||||||
| release 削除 | o | ||||||
| set as the latest release | |||||||
| unset as the latest release |
一部ドキュメントどおりに動作しない event があった
- draft 消しても deleted が起こらない
- draft 生成しても created が起こらない
あと latest を変更したり、 asset を変更しても event が発生しない
- released
- prereleased
- deleted
で良さそう
unpublished とは何か。 draft のことのような気はするが、 web ui からは release, prerelease を draft に変更することは出来ないように見える