diff --git a/src/Runner.Common/Constants.cs b/src/Runner.Common/Constants.cs index b9eeb6e81..42fb9dcbe 100644 --- a/src/Runner.Common/Constants.cs +++ b/src/Runner.Common/Constants.cs @@ -149,6 +149,7 @@ namespace GitHub.Runner.Common public static class Features { public static readonly string DiskSpaceWarning = "runner.diskspace.warning"; + public static readonly string Node12Warning = "DistributedTask.AddWarningToNode12Action"; } public static readonly string InternalTelemetryIssueDataKey = "_internal_telemetry"; @@ -158,6 +159,7 @@ namespace GitHub.Runner.Common public static readonly string UnsupportedCommandMessageDisabled = "The `{0}` command is disabled. Please upgrade to using Environment Files or opt into unsecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_COMMANDS` environment variable to `true`. For more information see: https://github.blog/changelog/2020-10-01-github-actions-deprecating-set-env-and-add-path-commands/"; public static readonly string UnsupportedStopCommandTokenDisabled = "You cannot use a endToken that is an empty string, the string 'pause-logging', or another workflow command. For more information see: https://docs.github.com/actions/learn-github-actions/workflow-commands-for-github-actions#example-stopping-and-starting-workflow-commands or opt into insecure command execution by setting the `ACTIONS_ALLOW_UNSECURE_STOPCOMMAND_TOKENS` environment variable to `true`."; public static readonly string UnsupportedSummarySize = "$GITHUB_STEP_SUMMARY upload aborted, supports content up to a size of {0}k, got {1}k. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary"; + public static readonly string Node12DetectedAfterEndOfLife = "Node.js 12 actions are deprecated. Please update the following actions to use Node.js 16: {0}"; } public static class RunnerEvent diff --git a/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs b/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs index bd4cfc672..cc8cedfd0 100644 --- a/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs +++ b/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs @@ -3,6 +3,8 @@ using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; +using GitHub.DistributedTask.Pipelines; +using GitHub.DistributedTask.Pipelines.ContextData; using GitHub.DistributedTask.WebApi; using GitHub.Runner.Common; using GitHub.Runner.Sdk; @@ -112,6 +114,17 @@ namespace GitHub.Runner.Worker.Handlers // Remove environment variable that may cause conflicts with the node within the runner. Environment.Remove("NODE_ICU_DATA"); // https://github.com/actions/runner/issues/795 + if (Data.NodeVersion == "node12" && (ExecutionContext.Global.Variables.GetBoolean(Constants.Runner.Features.Node12Warning) ?? false)) + { + if (!ExecutionContext.JobContext.ContainsKey("Node12ActionsWarnings")) + { + ExecutionContext.JobContext["Node12ActionsWarnings"] = new ArrayContextData(); + } + var repoAction = Action as RepositoryPathReference; + var actionDisplayName = new StringContextData(repoAction.Name ?? repoAction.Path); // local actions don't have a 'Name' + ExecutionContext.JobContext["Node12ActionsWarnings"].AssertArray("Node12ActionsWarnings").Add(actionDisplayName); + } + using (var stdoutManager = new OutputManager(ExecutionContext, ActionCommandManager)) using (var stderrManager = new OutputManager(ExecutionContext, ActionCommandManager)) { diff --git a/src/Runner.Worker/JobRunner.cs b/src/Runner.Worker/JobRunner.cs index 74b142885..ac2ebd42a 100644 --- a/src/Runner.Worker/JobRunner.cs +++ b/src/Runner.Worker/JobRunner.cs @@ -6,6 +6,7 @@ using System.Net.Http; using System.Text; using System.Threading; using System.Threading.Tasks; +using GitHub.DistributedTask.Pipelines.ContextData; using GitHub.DistributedTask.WebApi; using GitHub.Runner.Common; using GitHub.Runner.Common.Util; @@ -257,6 +258,12 @@ namespace GitHub.Runner.Worker } } + if (jobContext.JobContext.ContainsKey("Node12ActionsWarnings")) + { + var actions = string.Join(", ", jobContext.JobContext["Node12ActionsWarnings"].AssertArray("Node12ActionsWarnings").Select(action => action.ToString())); + jobContext.Warning(string.Format(Constants.Runner.Node12DetectedAfterEndOfLife, actions)); + } + try { await ShutdownQueue(throwOnFailure: true); diff --git a/src/Runner.Worker/StepsRunner.cs b/src/Runner.Worker/StepsRunner.cs index 82c9218ba..47f9d4c59 100644 --- a/src/Runner.Worker/StepsRunner.cs +++ b/src/Runner.Worker/StepsRunner.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks;