Skip to content

Commit 5a26a8c

Browse files
K0Teandreasabel
andauthored
Implement Actions API. (#459)
New data structures and endpoints to access the GitHub Actions API. Commit squashed from the following commits: * Implement actions->artifacts API. * Up * Cleanup * Actions - cache. * Actions - artifacts and cache. * Secrets * Workflows. * WorkflowJobs. * WorkflowRuns. * Format * Artifacts QA. * Cache QA. * Secrets QA. * WorkflowJobs QA. * Workflows QA. * Format. * Drop slack-related files. * Format JSON * Support workflow name in workflowRunsForWorkflowR. * Support workflow name in Workflows.hs. * Fix * Fix * Do not parse pull requests from workflow runs. * Avoid parsing 'trigerring_actor', it is sometimes missing. * Fix workflow run conclusion parsing. * Whitespace and lexical changes only * Remove outdated maintainer from module headers * Whitespace: align code * Bump cabal-version to 2.4 for globbing * Cosmetics: use (<&>) * Restore upper bounds for openssl etc. in .cabal file * Whitespace * Add haddocks for WithTotalCount * Changelog for PR #459 --------- Co-authored-by: Andreas Abel <[email protected]>
1 parent 69404f7 commit 5a26a8c

36 files changed

+2870
-6
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ run.sh
1818
src/hightlight.js
1919
src/style.css
2020
TAGS
21+
.DS_Store
22+

CHANGELOG.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
## Changes for 0.29
22

3-
_2022-06-24, Andreas Abel, Midsommar edition_
3+
_2023-06-24, Andreas Abel, Midsommar edition_
4+
5+
- Support for the GitHub Actions API
6+
(PR [#459](https://github.com/haskell-github/github/pull/459)):
7+
* New endpoint modules `GitHub.EndPoints.Actions.Artifacts`, `.Cache`,
8+
`.Secrets`, `.Workflows`, `.WorkflowRuns`, `.WorkflowJobs`.
9+
* Matching data structure modules `GitHub.Data.Actions.*`.
410

511
- Add field `issueStateReason` of type `Maybe IssueStateReason` to `Issue`
612
with possible values `completed`, `not_planned` and `reopened`

fixtures/actions/artifact.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"id": 416767789,
3+
"node_id": "MDg6QXJ0aWZhY3Q0MTY3Njc3ODk=",
4+
"name": "dist-without-markdown",
5+
"size_in_bytes": 42718,
6+
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/artifacts/416767789",
7+
"archive_download_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/artifacts/416767789/zip",
8+
"expired": false,
9+
"created_at": "2022-10-29T22:18:21Z",
10+
"updated_at": "2022-10-29T22:18:23Z",
11+
"expires_at": "2023-01-27T22:18:16Z",
12+
"workflow_run": {
13+
"id": 3353148947,
14+
"repository_id": 559365297,
15+
"head_repository_id": 559365297,
16+
"head_branch": "main",
17+
"head_sha": "601593ecb1d8a57a04700fdb445a28d4186b8954"
18+
}
19+
}

fixtures/actions/artifacts-list.json

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"total_count": 23809,
3+
"artifacts": [
4+
{
5+
"id": 416737084,
6+
"node_id": "MDg6QXJ0aWZhY3Q0MTY3MzcwODQ=",
7+
"name": "doc-html",
8+
"size_in_bytes": 61667543,
9+
"url": "https://api.github.com/repos/python/cpython/actions/artifacts/416737084",
10+
"archive_download_url": "https://api.github.com/repos/python/cpython/actions/artifacts/416737084/zip",
11+
"expired": false,
12+
"created_at": "2022-10-29T20:56:24Z",
13+
"updated_at": "2022-10-29T20:56:25Z",
14+
"expires_at": "2023-01-27T20:50:21Z",
15+
"workflow_run": {
16+
"id": 3352897496,
17+
"repository_id": 81598961,
18+
"head_repository_id": 101955313,
19+
"head_branch": "backport-bfecff5-3.11",
20+
"head_sha": "692cd77975413d71ff0951072df686e6f38711c8"
21+
}
22+
},
23+
{
24+
"id": 416712612,
25+
"node_id": "MDg6QXJ0aWZhY3Q0MTY3MTI2MTI=",
26+
"name": "doc-html",
27+
"size_in_bytes": 61217330,
28+
"url": "https://api.github.com/repos/python/cpython/actions/artifacts/416712612",
29+
"archive_download_url": "https://api.github.com/repos/python/cpython/actions/artifacts/416712612/zip",
30+
"expired": false,
31+
"created_at": "2022-10-29T19:53:19Z",
32+
"updated_at": "2022-10-29T19:53:20Z",
33+
"expires_at": "2023-01-27T19:49:12Z",
34+
"workflow_run": {
35+
"id": 3352724493,
36+
"repository_id": 81598961,
37+
"head_repository_id": 559335486,
38+
"head_branch": "patch-1",
39+
"head_sha": "62eb88a66d1d35f7701873d8b698a2f8d7e84fa5"
40+
}
41+
}
42+
]
43+
}

fixtures/actions/cache-list.json

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"total_count": 1,
3+
"actions_caches": [
4+
{
5+
"id": 1,
6+
"ref": "refs/heads/main",
7+
"key": "cache_key",
8+
"version": "f5f850afdadd47730296d4ffa900de95f6bbafb75dc1e8475df1fa6ae79dcece",
9+
"last_accessed_at": "2022-10-30T00:08:14.223333300Z",
10+
"created_at": "2022-10-30T00:08:14.223333300Z",
11+
"size_in_bytes": 26586
12+
}
13+
]
14+
}

fixtures/actions/org-cache-usage.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"total_active_caches_size_in_bytes": 26586,
3+
"total_active_caches_count": 1
4+
}

fixtures/actions/org-public-key.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"key_id": "568250167242549743",
3+
"key": "KHVvOxB765kjkShEgUu27QCzl5XxKz/L20V+KRsWf0w="
4+
}
+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"total_count": 2,
3+
"secrets": [
4+
{
5+
"name": "TEST_SECRET",
6+
"created_at": "2022-10-31T00:08:12Z",
7+
"updated_at": "2022-10-31T00:08:12Z",
8+
"visibility": "all"
9+
},
10+
{
11+
"name": "TEST_SELECTED",
12+
"created_at": "2022-10-31T00:08:43Z",
13+
"updated_at": "2022-10-31T00:08:43Z",
14+
"visibility": "selected",
15+
"selected_repositories_url": "https://api.github.com/orgs/kote-test-org-actions/actions/secrets/TEST_SELECTED/repositories"
16+
}
17+
]
18+
}
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"full_name": "python/cpython",
3+
"active_caches_size_in_bytes": 55000268087,
4+
"active_caches_count": 171
5+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
{
2+
"total_count": 1,
3+
"repositories": [
4+
{
5+
"id": 559365297,
6+
"node_id": "R_kgDOIVc8sQ",
7+
"name": "actions-api",
8+
"full_name": "kote-test-org-actions/actions-api",
9+
"private": true,
10+
"owner": {
11+
"login": "kote-test-org-actions",
12+
"id": 116976977,
13+
"node_id": "O_kgDOBvjtUQ",
14+
"avatar_url": "https://avatars.githubusercontent.com/u/116976977?v=4",
15+
"gravatar_id": "",
16+
"url": "https://api.github.com/users/kote-test-org-actions",
17+
"html_url": "https://github.com/kote-test-org-actions",
18+
"followers_url": "https://api.github.com/users/kote-test-org-actions/followers",
19+
"following_url": "https://api.github.com/users/kote-test-org-actions/following{/other_user}",
20+
"gists_url": "https://api.github.com/users/kote-test-org-actions/gists{/gist_id}",
21+
"starred_url": "https://api.github.com/users/kote-test-org-actions/starred{/owner}{/repo}",
22+
"subscriptions_url": "https://api.github.com/users/kote-test-org-actions/subscriptions",
23+
"organizations_url": "https://api.github.com/users/kote-test-org-actions/orgs",
24+
"repos_url": "https://api.github.com/users/kote-test-org-actions/repos",
25+
"events_url": "https://api.github.com/users/kote-test-org-actions/events{/privacy}",
26+
"received_events_url": "https://api.github.com/users/kote-test-org-actions/received_events",
27+
"type": "Organization",
28+
"site_admin": false
29+
},
30+
"html_url": "https://github.com/kote-test-org-actions/actions-api",
31+
"description": null,
32+
"fork": false,
33+
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api",
34+
"forks_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/forks",
35+
"keys_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/keys{/key_id}",
36+
"collaborators_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/collaborators{/collaborator}",
37+
"teams_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/teams",
38+
"hooks_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/hooks",
39+
"issue_events_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/issues/events{/number}",
40+
"events_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/events",
41+
"assignees_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/assignees{/user}",
42+
"branches_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/branches{/branch}",
43+
"tags_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/tags",
44+
"blobs_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/blobs{/sha}",
45+
"git_tags_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/tags{/sha}",
46+
"git_refs_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/refs{/sha}",
47+
"trees_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/trees{/sha}",
48+
"statuses_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/statuses/{sha}",
49+
"languages_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/languages",
50+
"stargazers_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/stargazers",
51+
"contributors_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/contributors",
52+
"subscribers_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/subscribers",
53+
"subscription_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/subscription",
54+
"commits_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/commits{/sha}",
55+
"git_commits_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/git/commits{/sha}",
56+
"comments_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/comments{/number}",
57+
"issue_comment_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/issues/comments{/number}",
58+
"contents_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/contents/{+path}",
59+
"compare_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/compare/{base}...{head}",
60+
"merges_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/merges",
61+
"archive_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/{archive_format}{/ref}",
62+
"downloads_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/downloads",
63+
"issues_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/issues{/number}",
64+
"pulls_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/pulls{/number}",
65+
"milestones_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/milestones{/number}",
66+
"notifications_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/notifications{?since,all,participating}",
67+
"labels_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/labels{/name}",
68+
"releases_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/releases{/id}",
69+
"deployments_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/deployments"
70+
}
71+
]
72+
}

fixtures/actions/workflow-job.json

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
{
2+
"id": 9183275828,
3+
"run_id": 3353449941,
4+
"run_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/runs/3353449941",
5+
"run_attempt": 1,
6+
"node_id": "CR_kwDOIVc8sc8AAAACI12rNA",
7+
"head_sha": "3156f684232a3adec5085c920d2006aca80f2798",
8+
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/jobs/9183275828",
9+
"html_url": "https://github.com/kote-test-org-actions/actions-api/actions/runs/3353449941/jobs/5556228789",
10+
"status": "completed",
11+
"conclusion": "success",
12+
"started_at": "2022-10-30T00:09:29Z",
13+
"completed_at": "2022-10-30T00:09:49Z",
14+
"name": "check-bats-version",
15+
"steps": [
16+
{
17+
"name": "Set up job",
18+
"status": "completed",
19+
"conclusion": "success",
20+
"number": 1,
21+
"started_at": "2022-10-29T17:09:29.000-07:00",
22+
"completed_at": "2022-10-29T17:09:32.000-07:00"
23+
},
24+
{
25+
"name": "Run actions/checkout@v3",
26+
"status": "completed",
27+
"conclusion": "success",
28+
"number": 2,
29+
"started_at": "2022-10-29T17:09:32.000-07:00",
30+
"completed_at": "2022-10-29T17:09:33.000-07:00"
31+
},
32+
{
33+
"name": "Run actions/setup-node@v3",
34+
"status": "completed",
35+
"conclusion": "success",
36+
"number": 3,
37+
"started_at": "2022-10-29T17:09:34.000-07:00",
38+
"completed_at": "2022-10-29T17:09:39.000-07:00"
39+
},
40+
{
41+
"name": "Run npm install -g bats",
42+
"status": "completed",
43+
"conclusion": "success",
44+
"number": 4,
45+
"started_at": "2022-10-29T17:09:40.000-07:00",
46+
"completed_at": "2022-10-29T17:09:42.000-07:00"
47+
},
48+
{
49+
"name": "Run bats -v",
50+
"status": "completed",
51+
"conclusion": "success",
52+
"number": 5,
53+
"started_at": "2022-10-29T17:09:42.000-07:00",
54+
"completed_at": "2022-10-29T17:09:42.000-07:00"
55+
},
56+
{
57+
"name": "Archive Test",
58+
"status": "completed",
59+
"conclusion": "success",
60+
"number": 6,
61+
"started_at": "2022-10-29T17:09:42.000-07:00",
62+
"completed_at": "2022-10-29T17:09:46.000-07:00"
63+
},
64+
{
65+
"name": "Cache",
66+
"status": "completed",
67+
"conclusion": "success",
68+
"number": 7,
69+
"started_at": "2022-10-29T17:09:46.000-07:00",
70+
"completed_at": "2022-10-29T17:09:47.000-07:00"
71+
},
72+
{
73+
"name": "Post Cache",
74+
"status": "completed",
75+
"conclusion": "success",
76+
"number": 12,
77+
"started_at": "2022-10-29T17:09:49.000-07:00",
78+
"completed_at": "2022-10-29T17:09:47.000-07:00"
79+
},
80+
{
81+
"name": "Post Run actions/setup-node@v3",
82+
"status": "completed",
83+
"conclusion": "success",
84+
"number": 13,
85+
"started_at": "2022-10-29T17:09:49.000-07:00",
86+
"completed_at": "2022-10-29T17:09:49.000-07:00"
87+
},
88+
{
89+
"name": "Post Run actions/checkout@v3",
90+
"status": "completed",
91+
"conclusion": "success",
92+
"number": 14,
93+
"started_at": "2022-10-29T17:09:49.000-07:00",
94+
"completed_at": "2022-10-29T17:09:49.000-07:00"
95+
},
96+
{
97+
"name": "Complete job",
98+
"status": "completed",
99+
"conclusion": "success",
100+
"number": 15,
101+
"started_at": "2022-10-29T17:09:47.000-07:00",
102+
"completed_at": "2022-10-29T17:09:47.000-07:00"
103+
}
104+
],
105+
"check_run_url": "https://api.github.com/repos/kote-test-org-actions/actions-api/check-runs/9183275828",
106+
"labels": [
107+
"ubuntu-latest"
108+
],
109+
"runner_id": 1,
110+
"runner_name": "Hosted Agent",
111+
"runner_group_id": 2,
112+
"runner_group_name": "GitHub Actions"
113+
}

fixtures/actions/workflow-list.json

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"total_count": 1,
3+
"workflows": [
4+
{
5+
"id": 39065091,
6+
"node_id": "W_kwDOIVc8sc4CVBYD",
7+
"name": "learn-github-actions",
8+
"path": ".github/workflows/make_artifact.yaml",
9+
"state": "active",
10+
"created_at": "2022-10-29T15:17:59.000-07:00",
11+
"updated_at": "2022-10-29T15:17:59.000-07:00",
12+
"url": "https://api.github.com/repos/kote-test-org-actions/actions-api/actions/workflows/39065091",
13+
"html_url": "https://github.com/kote-test-org-actions/actions-api/blob/main/.github/workflows/make_artifact.yaml",
14+
"badge_url": "https://github.com/kote-test-org-actions/actions-api/workflows/learn-github-actions/badge.svg"
15+
}
16+
]
17+
}

0 commit comments

Comments
 (0)