mirror of
https://github.com/actions/runner.git
synced 2025-12-11 12:57:05 +00:00
First prototype of step summary environment variable
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -103,6 +104,10 @@ namespace GitHub.Runner.Worker
|
||||
// Set GITHUB_ACTION
|
||||
step.ExecutionContext.SetGitHubContext("action", actionStep.Action.Name);
|
||||
|
||||
var stepSummaryFilePath = GetStepSummaryPath(step);
|
||||
step.ExecutionContext.SetGitHubContext("step_summary", stepSummaryFilePath);
|
||||
envContext["GITHUB_STEP_SUMMARY"] = new StringContextData(stepSummaryFilePath);
|
||||
|
||||
try
|
||||
{
|
||||
// Evaluate and merge step env
|
||||
@@ -351,8 +356,29 @@ namespace GitHub.Runner.Worker
|
||||
private void CompleteStep(IStep step, TaskResult? result = null, string resultCode = null)
|
||||
{
|
||||
var executionContext = step.ExecutionContext;
|
||||
var stepSummaryFilePath = executionContext.GetGitHubContext("step_summary");
|
||||
|
||||
Trace.Info($"Reading step summary data from {stepSummaryFilePath}");
|
||||
Trace.Info($"File exists: {stepSummaryFilePath} {File.Exists(stepSummaryFilePath)}");
|
||||
|
||||
var fileStream = new FileStream(stepSummaryFilePath, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
using (var sr = new StreamReader(fileStream))
|
||||
{
|
||||
Trace.Info(sr.ReadToEnd());
|
||||
}
|
||||
|
||||
executionContext.Complete(result, resultCode: resultCode);
|
||||
}
|
||||
|
||||
private string GetStepSummaryPath(IStep step)
|
||||
{
|
||||
var tempDirectory = HostContext.GetDirectory(WellKnownDirectory.Temp);
|
||||
Trace.Info($"Using temp directory '{tempDirectory}'");
|
||||
var stepSummaryFilePath = Path.Join(tempDirectory, $"{Guid.NewGuid().ToString()}.md");
|
||||
Trace.Info($"Using step summary file '{stepSummaryFilePath}'");
|
||||
File.Create(stepSummaryFilePath);
|
||||
|
||||
return stepSummaryFilePath;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
2.286.0
|
||||
2.286.2
|
||||
|
||||
Reference in New Issue
Block a user