@@ -15,6 +15,7 @@ import (
1515 "code.gitea.io/gitea/modules/git"
1616 "code.gitea.io/gitea/modules/json"
1717 "code.gitea.io/gitea/modules/setting"
18+ "code.gitea.io/gitea/modules/util"
1819
1920 "github.com/nektos/act/pkg/model"
2021)
@@ -167,34 +168,34 @@ func mergeTwoOutputs(o1, o2 map[string]string) map[string]string {
167168
168169func (g * GiteaContext ) ToGitHubContext () * model.GithubContext {
169170 return & model.GithubContext {
170- Event : (* g )[ "event" ].( map [string ]any ),
171- EventPath : (* g )[ "event_path" ].( string ),
172- Workflow : (* g )[ "workflow" ].( string ),
173- RunID : (* g )[ "run_id" ].( string ),
174- RunNumber : (* g )[ "run_number" ].( string ),
175- Actor : (* g )[ "actor" ].( string ),
176- Repository : (* g )[ "repository" ].( string ),
177- EventName : (* g )[ "event_name" ].( string ),
178- Sha : (* g )[ "sha" ].( string ),
179- Ref : (* g )[ "ref" ].( string ),
180- RefName : (* g )[ "ref_name" ].( string ),
181- RefType : (* g )[ "ref_type" ].( string ),
182- HeadRef : (* g )[ "head_ref" ].( string ),
183- BaseRef : (* g )[ "base_ref" ].( string ),
171+ Event : util . GetMapValueOrDefault (* g , "event" , map [string ]any ( nil ) ),
172+ EventPath : util . GetMapValueOrDefault (* g , "event_path" , "" ),
173+ Workflow : util . GetMapValueOrDefault (* g , "workflow" , "" ),
174+ RunID : util . GetMapValueOrDefault (* g , "run_id" , "" ),
175+ RunNumber : util . GetMapValueOrDefault (* g , "run_number" , "" ),
176+ Actor : util . GetMapValueOrDefault (* g , "actor" , "" ),
177+ Repository : util . GetMapValueOrDefault (* g , "repository" , "" ),
178+ EventName : util . GetMapValueOrDefault (* g , "event_name" , "" ),
179+ Sha : util . GetMapValueOrDefault (* g , "sha" , "" ),
180+ Ref : util . GetMapValueOrDefault (* g , "ref" , "" ),
181+ RefName : util . GetMapValueOrDefault (* g , "ref_name" , "" ),
182+ RefType : util . GetMapValueOrDefault (* g , "ref_type" , "" ),
183+ HeadRef : util . GetMapValueOrDefault (* g , "head_ref" , "" ),
184+ BaseRef : util . GetMapValueOrDefault (* g , "base_ref" , "" ),
184185 Token : "" , // deliberately omitted for security
185- Workspace : (* g )[ "workspace" ].( string ),
186- Action : (* g )[ "action" ].( string ),
187- ActionPath : (* g )[ "action_path" ].( string ),
188- ActionRef : (* g )[ "action_ref" ].( string ),
189- ActionRepository : (* g )[ "action_repository" ].( string ),
190- Job : (* g )[ "job" ].( string ),
186+ Workspace : util . GetMapValueOrDefault (* g , "workspace" , "" ),
187+ Action : util . GetMapValueOrDefault (* g , "action" , "" ),
188+ ActionPath : util . GetMapValueOrDefault (* g , "action_path" , "" ),
189+ ActionRef : util . GetMapValueOrDefault (* g , "action_ref" , "" ),
190+ ActionRepository : util . GetMapValueOrDefault (* g , "action_repository" , "" ),
191+ Job : util . GetMapValueOrDefault (* g , "job" , "" ),
191192 JobName : "" , // not present in GiteaContext
192- RepositoryOwner : (* g )[ "repository_owner" ].( string ),
193- RetentionDays : (* g )[ "retention_days" ].( string ),
193+ RepositoryOwner : util . GetMapValueOrDefault (* g , "repository_owner" , "" ),
194+ RetentionDays : util . GetMapValueOrDefault (* g , "retention_days" , "" ),
194195 RunnerPerflog : "" , // not present in GiteaContext
195196 RunnerTrackingID : "" , // not present in GiteaContext
196- ServerURL : (* g )[ "server_url" ].( string ),
197- APIURL : (* g )[ "api_url" ].( string ),
198- GraphQLURL : (* g )[ "graphql_url" ].( string ),
197+ ServerURL : util . GetMapValueOrDefault (* g , "server_url" , "" ),
198+ APIURL : util . GetMapValueOrDefault (* g , "api_url" , "" ),
199+ GraphQLURL : util . GetMapValueOrDefault (* g , "graphql_url" , "" ),
199200 }
200201}
0 commit comments