Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Workflows associated to deployment environments #260

Merged
merged 3 commits into from
Apr 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Octokit.Webhooks/Events/WorkflowJob/WorkflowJobAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public sealed record WorkflowJobAction : WebhookEventAction

public static readonly WorkflowJobAction Completed = new(WorkflowJobActionValue.Completed);

public static readonly WorkflowJobAction Waiting = new(WorkflowJobActionValue.Waiting);

private WorkflowJobAction(string value)
: base(value)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ public static class WorkflowJobActionValue
public const string InProgress = "in_progress";

public const string Completed = "completed";

public const string Waiting = "waiting";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Octokit.Webhooks.Events.WorkflowJob;

[PublicAPI]
[WebhookActionType(WorkflowJobActionValue.Waiting)]
public sealed record WorkflowJobWaitingEvent : WorkflowJobEvent
{
[JsonPropertyName("action")]
public override string Action => WorkflowJobAction.Waiting;
}
3 changes: 3 additions & 0 deletions src/Octokit.Webhooks/Events/WorkflowJobEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ public abstract record WorkflowJobEvent : WebhookEvent
{
[JsonPropertyName("workflow_job")]
public Models.WorkflowJobEvent.WorkflowJob WorkflowJob { get; init; } = null!;

[JsonPropertyName("deployment")]
public Models.DeploymentEvent.Deployment? Deployment { get; init; }
JamieMagee marked this conversation as resolved.
Show resolved Hide resolved
}
5 changes: 4 additions & 1 deletion src/Octokit.Webhooks/WebhookEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1136,11 +1136,14 @@ protected virtual Task ProcessWorkflowDispatchWebhookAsync(WebhookHeaders header
private Task ProcessWorkflowJobWebhookAsync(WebhookHeaders headers, WorkflowJobEvent workflowJobEvent) =>
workflowJobEvent.Action switch
{
WorkflowJobActionValue.Queued => this.ProcessWorkflowJobWebhookAsync(headers, workflowJobEvent, WorkflowJobAction.Queued),
WorkflowJobActionValue.Queued
=> this.ProcessWorkflowJobWebhookAsync(headers, workflowJobEvent, WorkflowJobAction.Queued),
WorkflowJobActionValue.InProgress
=> this.ProcessWorkflowJobWebhookAsync(headers, workflowJobEvent, WorkflowJobAction.InProgress),
WorkflowJobActionValue.Completed
=> this.ProcessWorkflowJobWebhookAsync(headers, workflowJobEvent, WorkflowJobAction.Completed),
WorkflowJobActionValue.Waiting
=> this.ProcessWorkflowJobWebhookAsync(headers, workflowJobEvent, WorkflowJobAction.Waiting),
_ => Task.CompletedTask,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,284 @@
{
"action": "queued",
"workflow_job": {
"id": 12877621891,
"run_id": 4747967848,
"workflow_name": "Env Test",
"head_branch": "main",
"run_url": "https://api.github.com/repos/lineville/elastic-machines-testing/actions/runs/4747967848",
"run_attempt": 1,
"node_id": "CR_kwDOI0B2Tc8AAAAC_5Dqgw",
"head_sha": "16c5286e8d9a0629956a28938386b36608707a71",
"url": "https://api.github.com/repos/lineville/elastic-machines-testing/actions/jobs/12877621891",
"html_url": "https://github.com/lineville/elastic-machines-testing/actions/runs/4747967848/jobs/8433573014",
"status": "waiting",
"conclusion": null,
"created_at": "2023-04-19T21:12:12Z",
"started_at": "2023-04-19T21:12:12Z",
"completed_at": null,
"name": "test",
"steps": [],
"check_run_url": "https://api.github.com/repos/lineville/elastic-machines-testing/check-runs/12877621891",
"labels": [
"self-hosted",
"k8s"
],
"runner_id": null,
"runner_name": null,
"runner_group_id": null,
"runner_group_name": null
},
"deployment": {
"url": "https://api.github.com/repos/lineville/elastic-machines-testing/deployments/875096709",
"id": 875096709,
"node_id": "DE_kwDOI0B2Tc40KOqF",
"task": "deploy",
"original_environment": "Test",
"environment": "Test",
"description": null,
"created_at": "2023-04-19T21:12:12Z",
"updated_at": "2023-04-19T21:12:14Z",
"statuses_url": "https://api.github.com/repos/lineville/elastic-machines-testing/deployments/875096709/statuses",
"repository_url": "https://api.github.com/repos/lineville/elastic-machines-testing",
"creator": {
"login": "lineville",
"id": 25349044,
"node_id": "MDQ6VXNlcjI1MzQ5MDQ0",
"avatar_url": "https://avatars.githubusercontent.com/u/25349044?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lineville",
"html_url": "https://github.com/lineville",
"followers_url": "https://api.github.com/users/lineville/followers",
"following_url": "https://api.github.com/users/lineville/following{/other_user}",
"gists_url": "https://api.github.com/users/lineville/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lineville/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lineville/subscriptions",
"organizations_url": "https://api.github.com/users/lineville/orgs",
"repos_url": "https://api.github.com/users/lineville/repos",
"events_url": "https://api.github.com/users/lineville/events{/privacy}",
"received_events_url": "https://api.github.com/users/lineville/received_events",
"type": "User",
"site_admin": true
},
"sha": "16c5286e8d9a0629956a28938386b36608707a71",
"ref": "main",
"payload": {},
"transient_environment": false,
"production_environment": false,
"performed_via_github_app": {
"id": 15368,
"slug": "github-actions",
"node_id": "MDM6QXBwMTUzNjg=",
"owner": {
"login": "github",
"id": 9919,
"node_id": "MDEyOk9yZ2FuaXphdGlvbjk5MTk=",
"avatar_url": "https://avatars.githubusercontent.com/u/9919?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/github",
"html_url": "https://github.com/github",
"followers_url": "https://api.github.com/users/github/followers",
"following_url": "https://api.github.com/users/github/following{/other_user}",
"gists_url": "https://api.github.com/users/github/gists{/gist_id}",
"starred_url": "https://api.github.com/users/github/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/github/subscriptions",
"organizations_url": "https://api.github.com/users/github/orgs",
"repos_url": "https://api.github.com/users/github/repos",
"events_url": "https://api.github.com/users/github/events{/privacy}",
"received_events_url": "https://api.github.com/users/github/received_events",
"type": "Organization",
"site_admin": false
},
"name": "GitHub Actions",
"description": "Automate your workflow from idea to production",
"external_url": "https://help.github.com/en/actions",
"html_url": "https://github.com/apps/github-actions",
"created_at": "2018-07-30T09:30:17Z",
"updated_at": "2019-12-10T19:04:12Z",
"permissions": {
"actions": "write",
"administration": "read",
"checks": "write",
"contents": "write",
"deployments": "write",
"discussions": "write",
"issues": "write",
"merge_queues": "write",
"metadata": "read",
"packages": "write",
"pages": "write",
"pull_requests": "write",
"repository_hooks": "write",
"repository_projects": "write",
"security_events": "write",
"statuses": "write",
"vulnerability_alerts": "read"
},
"events": [
"branch_protection_rule",
"check_run",
"check_suite",
"create",
"delete",
"deployment",
"deployment_status",
"discussion",
"discussion_comment",
"fork",
"gollum",
"issues",
"issue_comment",
"label",
"merge_group",
"milestone",
"page_build",
"project",
"project_card",
"project_column",
"public",
"pull_request",
"pull_request_review",
"pull_request_review_comment",
"push",
"registry_package",
"release",
"repository",
"repository_dispatch",
"status",
"watch",
"workflow_dispatch",
"workflow_run"
]
}
},
"repository": {
"id": 591427149,
"node_id": "R_kgDOI0B2TQ",
"name": "elastic-machines-testing",
"full_name": "lineville/elastic-machines-testing",
"private": false,
"owner": {
"login": "lineville",
"id": 25349044,
"node_id": "MDQ6VXNlcjI1MzQ5MDQ0",
"avatar_url": "https://avatars.githubusercontent.com/u/25349044?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lineville",
"html_url": "https://github.com/lineville",
"followers_url": "https://api.github.com/users/lineville/followers",
"following_url": "https://api.github.com/users/lineville/following{/other_user}",
"gists_url": "https://api.github.com/users/lineville/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lineville/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lineville/subscriptions",
"organizations_url": "https://api.github.com/users/lineville/orgs",
"repos_url": "https://api.github.com/users/lineville/repos",
"events_url": "https://api.github.com/users/lineville/events{/privacy}",
"received_events_url": "https://api.github.com/users/lineville/received_events",
"type": "User",
"site_admin": true
},
"html_url": "https://github.com/lineville/elastic-machines-testing",
"description": "Testing Repo to simulate load for Elastic Machines",
"fork": false,
"url": "https://api.github.com/repos/lineville/elastic-machines-testing",
"forks_url": "https://api.github.com/repos/lineville/elastic-machines-testing/forks",
"keys_url": "https://api.github.com/repos/lineville/elastic-machines-testing/keys{/key_id}",
"collaborators_url": "https://api.github.com/repos/lineville/elastic-machines-testing/collaborators{/collaborator}",
"teams_url": "https://api.github.com/repos/lineville/elastic-machines-testing/teams",
"hooks_url": "https://api.github.com/repos/lineville/elastic-machines-testing/hooks",
"issue_events_url": "https://api.github.com/repos/lineville/elastic-machines-testing/issues/events{/number}",
"events_url": "https://api.github.com/repos/lineville/elastic-machines-testing/events",
"assignees_url": "https://api.github.com/repos/lineville/elastic-machines-testing/assignees{/user}",
"branches_url": "https://api.github.com/repos/lineville/elastic-machines-testing/branches{/branch}",
"tags_url": "https://api.github.com/repos/lineville/elastic-machines-testing/tags",
"blobs_url": "https://api.github.com/repos/lineville/elastic-machines-testing/git/blobs{/sha}",
"git_tags_url": "https://api.github.com/repos/lineville/elastic-machines-testing/git/tags{/sha}",
"git_refs_url": "https://api.github.com/repos/lineville/elastic-machines-testing/git/refs{/sha}",
"trees_url": "https://api.github.com/repos/lineville/elastic-machines-testing/git/trees{/sha}",
"statuses_url": "https://api.github.com/repos/lineville/elastic-machines-testing/statuses/{sha}",
"languages_url": "https://api.github.com/repos/lineville/elastic-machines-testing/languages",
"stargazers_url": "https://api.github.com/repos/lineville/elastic-machines-testing/stargazers",
"contributors_url": "https://api.github.com/repos/lineville/elastic-machines-testing/contributors",
"subscribers_url": "https://api.github.com/repos/lineville/elastic-machines-testing/subscribers",
"subscription_url": "https://api.github.com/repos/lineville/elastic-machines-testing/subscription",
"commits_url": "https://api.github.com/repos/lineville/elastic-machines-testing/commits{/sha}",
"git_commits_url": "https://api.github.com/repos/lineville/elastic-machines-testing/git/commits{/sha}",
"comments_url": "https://api.github.com/repos/lineville/elastic-machines-testing/comments{/number}",
"issue_comment_url": "https://api.github.com/repos/lineville/elastic-machines-testing/issues/comments{/number}",
"contents_url": "https://api.github.com/repos/lineville/elastic-machines-testing/contents/{+path}",
"compare_url": "https://api.github.com/repos/lineville/elastic-machines-testing/compare/{base}...{head}",
"merges_url": "https://api.github.com/repos/lineville/elastic-machines-testing/merges",
"archive_url": "https://api.github.com/repos/lineville/elastic-machines-testing/{archive_format}{/ref}",
"downloads_url": "https://api.github.com/repos/lineville/elastic-machines-testing/downloads",
"issues_url": "https://api.github.com/repos/lineville/elastic-machines-testing/issues{/number}",
"pulls_url": "https://api.github.com/repos/lineville/elastic-machines-testing/pulls{/number}",
"milestones_url": "https://api.github.com/repos/lineville/elastic-machines-testing/milestones{/number}",
"notifications_url": "https://api.github.com/repos/lineville/elastic-machines-testing/notifications{?since,all,participating}",
"labels_url": "https://api.github.com/repos/lineville/elastic-machines-testing/labels{/name}",
"releases_url": "https://api.github.com/repos/lineville/elastic-machines-testing/releases{/id}",
"deployments_url": "https://api.github.com/repos/lineville/elastic-machines-testing/deployments",
"created_at": "2023-01-20T18:23:59Z",
"updated_at": "2023-01-20T18:23:59Z",
"pushed_at": "2023-04-19T21:11:39Z",
"git_url": "git://github.com/lineville/elastic-machines-testing.git",
"ssh_url": "[email protected]:lineville/elastic-machines-testing.git",
"clone_url": "https://github.com/lineville/elastic-machines-testing.git",
"svn_url": "https://github.com/lineville/elastic-machines-testing",
"homepage": null,
"size": 39,
"stargazers_count": 0,
"watchers_count": 0,
"language": null,
"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": 0,
"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": [],
"visibility": "public",
"forks": 0,
"open_issues": 0,
"watchers": 0,
"default_branch": "main"
},
"sender": {
"login": "lineville",
"id": 25349044,
"node_id": "MDQ6VXNlcjI1MzQ5MDQ0",
"avatar_url": "https://avatars.githubusercontent.com/u/25349044?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/lineville",
"html_url": "https://github.com/lineville",
"followers_url": "https://api.github.com/users/lineville/followers",
"following_url": "https://api.github.com/users/lineville/following{/other_user}",
"gists_url": "https://api.github.com/users/lineville/gists{/gist_id}",
"starred_url": "https://api.github.com/users/lineville/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/lineville/subscriptions",
"organizations_url": "https://api.github.com/users/lineville/orgs",
"repos_url": "https://api.github.com/users/lineville/repos",
"events_url": "https://api.github.com/users/lineville/events{/privacy}",
"received_events_url": "https://api.github.com/users/lineville/received_events",
"type": "User",
"site_admin": true
},
"installation": {
"id": 23154469,
"node_id": "MDIzOkludGVncmF0aW9uSW5zdGFsbGF0aW9uMjMxNTQ0Njk="
}
}
Loading