@@ -277,6 +277,30 @@ func RunGraph(ctx context.Context, graphName string, graphContent []byte, opts R
277277 return CreateErr (nil , err , "failed to load yaml" )
278278 }
279279
280+ // Capture GITHUB_TOKEN / INPUT_GITHUB_TOKEN from the OS environment and store in
281+ // OverrideSecrets so it remains available for repo cloning (gh-action) and
282+ // is properly surfaced as secrets.GITHUB_TOKEN / github.token. Then remove
283+ // from the OS environment to prevent subprocesses from extracting it via
284+ // /proc/<ppid>/environ or similar.
285+ if opts .OverrideSecrets == nil {
286+ opts .OverrideSecrets = make (map [string ]string )
287+ }
288+ if _ , exists := opts .OverrideSecrets ["GITHUB_TOKEN" ]; ! exists {
289+ if ghToken , ok := opts .OverrideEnv ["GITHUB_TOKEN" ]; ok && ghToken != "" {
290+ opts .OverrideSecrets ["GITHUB_TOKEN" ] = ghToken
291+ } else if ghToken := os .Getenv ("GITHUB_TOKEN" ); ghToken != "" {
292+ opts .OverrideSecrets ["GITHUB_TOKEN" ] = ghToken
293+ } else if inputToken := os .Getenv ("INPUT_GITHUB_TOKEN" ); inputToken != "" {
294+ opts .OverrideSecrets ["GITHUB_TOKEN" ] = inputToken
295+ } else if inputToken := os .Getenv ("INPUT_TOKEN" ); inputToken != "" {
296+ opts .OverrideSecrets ["GITHUB_TOKEN" ] = inputToken
297+ }
298+ }
299+ delete (opts .OverrideEnv , "GITHUB_TOKEN" )
300+ os .Unsetenv ("GITHUB_TOKEN" )
301+ os .Unsetenv ("INPUT_GITHUB_TOKEN" )
302+ os .Unsetenv ("INPUT_TOKEN" )
303+
280304 ag , errs := LoadGraph (graphYaml , nil , "" , false , opts )
281305 if len (errs ) > 0 {
282306 return CreateErr (nil , errs [0 ], "failed to load graph" )
@@ -299,13 +323,13 @@ func RunGraph(ctx context.Context, graphName string, graphContent []byte, opts R
299323 isGitHubWorkflow := false
300324 if opts .OverrideEnv ["GITHUB_ACTIONS" ] == "true" {
301325 isGitHubWorkflow = true
302- utils .LogOut .Infof ("GitHub workflow detected via OverrideEnv" )
326+ utils .LogOut .Info ("GitHub workflow detected via OverrideEnv\n " )
303327 } else if os .Getenv ("GITHUB_ACTIONS" ) == "true" {
304328 isGitHubWorkflow = true
305- utils .LogOut .Infof ("GitHub workflow detected via GITHUB_ACTIONS environment variable (.env or shell)" )
329+ utils .LogOut .Info ("GitHub workflow detected via GITHUB_ACTIONS environment variable (.env or shell)\n " )
306330 } else if entryNode .GetNodeTypeId () == "core/gh-start@v1" {
307331 isGitHubWorkflow = true
308- utils .LogOut .Infof ("GitHub workflow detected via entry node type: core/gh-start@v1" )
332+ utils .LogOut .Info ("GitHub workflow detected via entry node type: core/gh-start@v1\n " )
309333 }
310334
311335 // mimickGitHubEnv: Determines if we need to set up a simulated GitHub environment. The easiest
@@ -406,7 +430,7 @@ func RunGraph(ctx context.Context, graphName string, graphContent []byte, opts R
406430 if m , err := decodeJsonFromEnvValue [any ](v .Value ); err == nil {
407431 needsTracker .set (m , source , true , true )
408432 }
409- case isGitHubWorkflow && k == "ACT_INPUT_TOKEN" :
433+ case isGitHubWorkflow && ( k == "ACT_INPUT_TOKEN" || k == "ACT_INPUT_GITHUB_TOKEN" ) :
410434 secretTracker .setSingle ("GITHUB_TOKEN" , v .Value , source , true , true )
411435
412436 default :
@@ -440,17 +464,19 @@ func RunGraph(ctx context.Context, graphName string, graphContent []byte, opts R
440464 }
441465
442466 if mimickGitHubEnv {
443- if cwd , ok := finalEnv ["GITHUB_WORKSPACE" ]; ok {
444- newCwd = cwd
445- utils .LogOut .Debugf ("changing working directory to GITHUB_WORKSPACE: %s\n " , newCwd )
446- }
447-
448467 // If we are running a github actions workflow, then mimic a GitHub Actions environment
449468 // But only do is if we are NOT already in GitHub Actions
450469 err = SetupGitHubActionsEnv (finalEnv )
451470 if err != nil {
452471 return CreateErr (nil , err , "failed to setup GitHub Actions environment" )
453472 }
473+
474+ // Use the updated GITHUB_WORKSPACE as the working directory.
475+ // SetupGitHubActionsEnv replaces GITHUB_WORKSPACE with a fresh temp folder.
476+ if cwd , ok := finalEnv ["GITHUB_WORKSPACE" ]; ok {
477+ newCwd = cwd
478+ utils .LogOut .Debugf ("changing working directory to GITHUB_WORKSPACE: %s\n " , newCwd )
479+ }
454480 } else if debugCb != nil && newCwd == "" {
455481 // for debug sessions, always create a temp working directory if none is set
456482 tmpDir , tmpErr := os .MkdirTemp ("" , "actrun-debug-*" )
0 commit comments