1
1
package runner
2
2
3
3
import (
4
+ "archive/tar"
5
+ "bufio"
4
6
"context"
5
7
"crypto/rand"
6
8
"encoding/hex"
7
9
"encoding/json"
8
10
"errors"
9
11
"fmt"
12
+ "io"
10
13
"os"
11
14
"path/filepath"
12
15
"regexp"
@@ -188,10 +191,6 @@ func (rc *RunContext) startHostEnvironment() common.Executor {
188
191
Name : "workflow/envs.txt" ,
189
192
Mode : 0666 ,
190
193
Body : "" ,
191
- }, & container.FileEntry {
192
- Name : "workflow/paths.txt" ,
193
- Mode : 0666 ,
194
- Body : "" ,
195
194
}),
196
195
)(ctx )
197
196
}
@@ -277,10 +276,6 @@ func (rc *RunContext) startJobContainer() common.Executor {
277
276
Name : "workflow/envs.txt" ,
278
277
Mode : 0666 ,
279
278
Body : "" ,
280
- }, & container.FileEntry {
281
- Name : "workflow/paths.txt" ,
282
- Mode : 0666 ,
283
- Body : "" ,
284
279
}),
285
280
)(ctx )
286
281
}
@@ -292,6 +287,41 @@ func (rc *RunContext) execJobContainer(cmd []string, env map[string]string, user
292
287
}
293
288
}
294
289
290
+ func (rc * RunContext ) ApplyExtraPath (env * map [string ]string ) {
291
+ if rc .ExtraPath != nil && len (rc .ExtraPath ) > 0 {
292
+ path := rc .JobContainer .GetPathVariableName ()
293
+ if (* env )[path ] == "" {
294
+ (* env )[path ] = rc .JobContainer .DefaultPathVariable ()
295
+ }
296
+ (* env )[path ] = rc .JobContainer .JoinPathVariable (append (rc .ExtraPath , (* env )[path ])... )
297
+ }
298
+ }
299
+
300
+ func (rc * RunContext ) UpdateExtraPath (ctx context.Context , githubEnvPath string ) error {
301
+ if common .Dryrun (ctx ) {
302
+ return nil
303
+ }
304
+ pathTar , err := rc .JobContainer .GetContainerArchive (ctx , githubEnvPath )
305
+ if err != nil {
306
+ return err
307
+ }
308
+ defer pathTar .Close ()
309
+
310
+ reader := tar .NewReader (pathTar )
311
+ _ , err = reader .Next ()
312
+ if err != nil && err != io .EOF {
313
+ return err
314
+ }
315
+ s := bufio .NewScanner (reader )
316
+ for s .Scan () {
317
+ line := s .Text ()
318
+ if len (line ) > 0 {
319
+ rc .addPath (ctx , line )
320
+ }
321
+ }
322
+ return nil
323
+ }
324
+
295
325
// stopJobContainer removes the job container (if it exists) and its volume (if it exists) if !rc.Config.ReuseContainers
296
326
func (rc * RunContext ) stopJobContainer () common.Executor {
297
327
return func (ctx context.Context ) error {
@@ -639,7 +669,6 @@ func nestedMapLookup(m map[string]interface{}, ks ...string) (rval interface{})
639
669
func (rc * RunContext ) withGithubEnv (ctx context.Context , github * model.GithubContext , env map [string ]string ) map [string ]string {
640
670
env ["CI" ] = "true"
641
671
env ["GITHUB_ENV" ] = rc .JobContainer .GetActPath () + "/workflow/envs.txt"
642
- env ["GITHUB_PATH" ] = rc .JobContainer .GetActPath () + "/workflow/paths.txt"
643
672
env ["GITHUB_WORKFLOW" ] = github .Workflow
644
673
env ["GITHUB_RUN_ID" ] = github .RunID
645
674
env ["GITHUB_RUN_NUMBER" ] = github .RunNumber
0 commit comments