@@ -75,7 +75,7 @@ module Actions {
7575 YamlMapping getJobs ( ) { result = this .lookup ( "jobs" ) }
7676
7777 /** Gets the 'global' `env` mapping in this workflow. */
78- YamlMapping getEnv ( ) { result = this .lookup ( "env" ) }
78+ WorkflowEnv getEnv ( ) { result = this .lookup ( "env" ) }
7979
8080 /** Gets the name of the workflow. */
8181 string getName ( ) { result = this .lookup ( "name" ) .( YamlString ) .getValue ( ) }
@@ -103,52 +103,36 @@ module Actions {
103103 Workflow getWorkflow ( ) { result = workflow }
104104 }
105105
106- /** An environment variable in 'env:' */
107- abstract class EnvVariable extends YamlNode , YamlString {
108- /** Gets the name of this environment variable. */
109- abstract string getName ( ) ;
110- }
106+ abstract class Env extends YamlNode , YamlMapping { }
111107
112- /** A workflow level 'global' environment variable. */
113- class WorkflowEnvVariable extends EnvVariable {
114- string envName ;
108+ /** A workflow level `env` mapping. */
109+ class WorkflowEnv extends Env {
115110 Workflow workflow ;
116111
117- WorkflowEnvVariable ( ) { this = workflow .getEnv ( ) . lookup ( envName ) }
112+ WorkflowEnv ( ) { workflow .lookup ( "env" ) = this }
118113
119114 /** Gets the workflow this field belongs to. */
120115 Workflow getWorkflow ( ) { result = workflow }
121-
122- /** Gets the name of this environment variable. */
123- override string getName ( ) { result = envName }
124116 }
125117
126- /** A job level environment variable. */
127- class JobEnvVariable extends EnvVariable {
128- string envName ;
118+ /** A job level `env` mapping. */
119+ class JobEnv extends Env {
129120 Job job ;
130121
131- JobEnvVariable ( ) { this = job .getEnv ( ) . lookup ( envName ) }
122+ JobEnv ( ) { job .lookup ( "env" ) = this }
132123
133124 /** Gets the job this field belongs to. */
134125 Job getJob ( ) { result = job }
135-
136- /** Gets the name of this environment variable. */
137- override string getName ( ) { result = envName }
138126 }
139127
140- /** A step level environment variable. */
141- class StepEnvVariable extends EnvVariable {
142- string envName ;
128+ /** A step level `env` mapping. */
129+ class StepEnv extends Env {
143130 Step step ;
144131
145- StepEnvVariable ( ) { this = step .getEnv ( ) . lookup ( envName ) }
132+ StepEnv ( ) { step .lookup ( "env" ) = this }
146133
147134 /** Gets the step this field belongs to. */
148135 Step getStep ( ) { result = step }
149-
150- /** Gets the name of this environment variable. */
151- override string getName ( ) { result = envName }
152136 }
153137
154138 /**
@@ -183,7 +167,7 @@ module Actions {
183167 Step getStep ( int index ) { result .getJob ( ) = this and result .getIndex ( ) = index }
184168
185169 /** Gets the `env` mapping in this job. */
186- YamlMapping getEnv ( ) { result = this .lookup ( "env" ) }
170+ JobEnv getEnv ( ) { result = this .lookup ( "env" ) }
187171
188172 /** Gets the workflow this job belongs to. */
189173 Workflow getWorkflow ( ) { result = workflow }
@@ -250,7 +234,7 @@ module Actions {
250234 StepIf getIf ( ) { result .getStep ( ) = this }
251235
252236 /** Gets the value of the `env` field in this step, if any. */
253- YamlMapping getEnv ( ) { result = this .lookup ( "env" ) }
237+ StepEnv getEnv ( ) { result = this .lookup ( "env" ) }
254238
255239 /** Gets the ID of this step, if any. */
256240 string getId ( ) { result = this .lookup ( "id" ) .( YamlString ) .getValue ( ) }
0 commit comments