1use serde::{Deserialize, Serialize};
12
13use crate::models;
14
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct GithubContext {
17 #[serde(rename = "action")]
18 pub action: String,
19 #[serde(rename = "action_path")]
20 pub action_path: String,
21 #[serde(rename = "action_ref")]
22 pub action_ref: String,
23 #[serde(rename = "action_repository")]
24 pub action_repository: String,
25 #[serde(rename = "action_status")]
26 pub action_status: String,
27 #[serde(rename = "actor")]
28 pub actor: String,
29 #[serde(rename = "actor_id")]
30 pub actor_id: String,
31 #[serde(rename = "api_url")]
32 pub api_url: String,
33 #[serde(rename = "base_ref")]
34 pub base_ref: String,
35 #[serde(rename = "env")]
36 pub env: String,
37 #[serde(rename = "event", deserialize_with = "Option::deserialize")]
38 pub event: Option<serde_json::Value>,
39 #[serde(rename = "event_name")]
40 pub event_name: String,
41 #[serde(rename = "event_path")]
42 pub event_path: String,
43 #[serde(rename = "graphql_url")]
44 pub graphql_url: String,
45 #[serde(rename = "head_ref")]
46 pub head_ref: String,
47 #[serde(rename = "job")]
48 pub job: String,
49 #[serde(rename = "path")]
50 pub path: String,
51 #[serde(rename = "ref")]
52 pub r#ref: String,
53 #[serde(rename = "ref_name")]
54 pub ref_name: String,
55 #[serde(rename = "ref_protected")]
56 pub ref_protected: bool,
57 #[serde(rename = "ref_type")]
58 pub ref_type: String,
59 #[serde(rename = "repository")]
60 pub repository: String,
61 #[serde(rename = "repositoryUrl")]
62 pub repository_url: String,
63 #[serde(rename = "repository_id")]
64 pub repository_id: String,
65 #[serde(rename = "repository_owner")]
66 pub repository_owner: String,
67 #[serde(rename = "repository_owner_id")]
68 pub repository_owner_id: String,
69 #[serde(rename = "retention_days")]
70 pub retention_days: String,
71 #[serde(rename = "run_attempt")]
72 pub run_attempt: String,
73 #[serde(rename = "run_id")]
74 pub run_id: String,
75 #[serde(rename = "run_number")]
76 pub run_number: String,
77 #[serde(rename = "secret_source")]
78 pub secret_source: String,
79 #[serde(rename = "server_url")]
80 pub server_url: String,
81 #[serde(rename = "sha")]
82 pub sha: String,
83 #[serde(rename = "token")]
84 pub token: String,
85 #[serde(rename = "triggering_actor")]
86 pub triggering_actor: String,
87 #[serde(rename = "workflow")]
88 pub workflow: String,
89 #[serde(rename = "workflow_ref")]
90 pub workflow_ref: String,
91 #[serde(rename = "workflow_sha")]
92 pub workflow_sha: String,
93 #[serde(rename = "workspace")]
94 pub workspace: String,
95}
96
97impl GithubContext {
98 pub fn new(
99 action: String,
100 action_path: String,
101 action_ref: String,
102 action_repository: String,
103 action_status: String,
104 actor: String,
105 actor_id: String,
106 api_url: String,
107 base_ref: String,
108 env: String,
109 event: Option<serde_json::Value>,
110 event_name: String,
111 event_path: String,
112 graphql_url: String,
113 head_ref: String,
114 job: String,
115 path: String,
116 r#ref: String,
117 ref_name: String,
118 ref_protected: bool,
119 ref_type: String,
120 repository: String,
121 repository_url: String,
122 repository_id: String,
123 repository_owner: String,
124 repository_owner_id: String,
125 retention_days: String,
126 run_attempt: String,
127 run_id: String,
128 run_number: String,
129 secret_source: String,
130 server_url: String,
131 sha: String,
132 token: String,
133 triggering_actor: String,
134 workflow: String,
135 workflow_ref: String,
136 workflow_sha: String,
137 workspace: String,
138 ) -> GithubContext {
139 GithubContext {
140 action,
141 action_path,
142 action_ref,
143 action_repository,
144 action_status,
145 actor,
146 actor_id,
147 api_url,
148 base_ref,
149 env,
150 event,
151 event_name,
152 event_path,
153 graphql_url,
154 head_ref,
155 job,
156 path,
157 r#ref,
158 ref_name,
159 ref_protected,
160 ref_type,
161 repository,
162 repository_url,
163 repository_id,
164 repository_owner,
165 repository_owner_id,
166 retention_days,
167 run_attempt,
168 run_id,
169 run_number,
170 secret_source,
171 server_url,
172 sha,
173 token,
174 triggering_actor,
175 workflow,
176 workflow_ref,
177 workflow_sha,
178 workspace,
179 }
180 }
181}