2023-06-02 21:47:59 +02:00
using System ;
2019-10-10 00:52:42 -04:00
namespace GitHub.Runner.Common
{
public enum WellKnownDirectory
{
Bin ,
Diag ,
Externals ,
Root ,
Actions ,
Temp ,
Tools ,
Update ,
Work ,
}
public enum WellKnownConfigFile
{
Runner ,
2025-03-19 12:37:08 -04:00
MigratedRunner ,
2019-10-10 00:52:42 -04:00
Credentials ,
2020-03-04 21:40:58 -05:00
MigratedCredentials ,
2019-10-10 00:52:42 -04:00
RSACredentials ,
Service ,
CredentialStore ,
Certificates ,
Options ,
2020-03-11 10:36:56 -04:00
SetupInfo ,
2021-09-29 15:49:31 -04:00
Telemetry
2019-10-10 00:52:42 -04:00
}
public static class Constants
{
/// <summary>Path environment variable name.</summary>
#if OS_WINDOWS
public static readonly string PathVariable = "Path" ;
#else
public static readonly string PathVariable = "PATH" ;
#endif
public static string ProcessTrackingId = "RUNNER_TRACKING_ID" ;
public static string PluginTracePrefix = "##[plugin.trace]" ;
public static readonly int RunnerDownloadRetryMaxAttempts = 3 ;
2021-07-01 13:34:28 -04:00
public static readonly int CompositeActionsMaxDepth = 9 ;
2019-10-10 00:52:42 -04:00
// This enum is embedded within the Constants class to make it easier to reference and avoid
// ambiguous type reference with System.Runtime.InteropServices.OSPlatform and System.Runtime.InteropServices.Architecture
public enum OSPlatform
{
OSX ,
Linux ,
Windows
}
public enum Architecture
{
X86 ,
X64 ,
Arm ,
Arm64
}
public static class Runner
{
#if OS_LINUX
public static readonly OSPlatform Platform = OSPlatform . Linux ;
#elif OS_OSX
public static readonly OSPlatform Platform = OSPlatform . OSX ;
#elif OS_WINDOWS
public static readonly OSPlatform Platform = OSPlatform . Windows ;
2023-09-26 16:49:15 -04:00
#else
public static readonly OSPlatform Platform = OSPlatform . Linux ;
2019-10-10 00:52:42 -04:00
#endif
#if X86
public static readonly Architecture PlatformArchitecture = Architecture . X86 ;
#elif X64
public static readonly Architecture PlatformArchitecture = Architecture . X64 ;
#elif ARM
public static readonly Architecture PlatformArchitecture = Architecture . Arm ;
2022-09-26 09:20:43 -04:00
#elif ARM64
2019-10-10 00:52:42 -04:00
public static readonly Architecture PlatformArchitecture = Architecture . Arm64 ;
2023-09-26 16:49:15 -04:00
#else
public static readonly Architecture PlatformArchitecture = Architecture . X64 ;
2019-10-10 00:52:42 -04:00
#endif
public static readonly TimeSpan ExitOnUnloadTimeout = TimeSpan . FromSeconds ( 30 ) ;
public static class CommandLine
{
//if you are adding a new arg, please make sure you update the
2022-04-11 15:23:58 +02:00
//validOptions dictionary as well present in the CommandSettings.cs
2019-10-10 00:52:42 -04:00
public static class Args
{
public static readonly string Auth = "auth" ;
2020-04-13 21:33:13 -04:00
public static readonly string Labels = "labels" ;
2019-10-10 00:52:42 -04:00
public static readonly string MonitorSocketAddress = "monitorsocketaddress" ;
2019-12-11 13:26:06 -05:00
public static readonly string Name = "name" ;
2020-07-23 17:46:48 -04:00
public static readonly string RunnerGroup = "runnergroup" ;
2019-10-10 00:52:42 -04:00
public static readonly string StartupType = "startuptype" ;
public static readonly string Url = "url" ;
public static readonly string UserName = "username" ;
public static readonly string WindowsLogonAccount = "windowslogonaccount" ;
public static readonly string Work = "work" ;
// Secret args. Must be added to the "Secrets" getter as well.
public static readonly string Token = "token" ;
2020-12-25 21:54:23 -05:00
public static readonly string PAT = "pat" ;
2019-10-10 00:52:42 -04:00
public static readonly string WindowsLogonPassword = "windowslogonpassword" ;
2022-12-21 19:30:22 +01:00
public static readonly string JitConfig = "jitconfig" ;
2019-10-10 00:52:42 -04:00
public static string [ ] Secrets = > new [ ]
{
2020-12-25 21:54:23 -05:00
PAT ,
2019-10-10 00:52:42 -04:00
Token ,
WindowsLogonPassword ,
2022-12-21 19:30:22 +01:00
JitConfig ,
2019-10-10 00:52:42 -04:00
} ;
}
public static class Commands
{
public static readonly string Configure = "configure" ;
public static readonly string Remove = "remove" ;
public static readonly string Run = "run" ;
public static readonly string Warmup = "warmup" ;
}
//if you are adding a new flag, please make sure you update the
2022-04-11 15:23:58 +02:00
//validOptions dictionary as well present in the CommandSettings.cs
2019-10-10 00:52:42 -04:00
public static class Flags
{
2021-01-14 13:26:07 -05:00
public static readonly string Check = "check" ;
2019-10-10 00:52:42 -04:00
public static readonly string Commit = "commit" ;
2021-09-13 11:28:09 -04:00
public static readonly string Ephemeral = "ephemeral" ;
2022-10-26 08:48:23 -04:00
public static readonly string GenerateServiceConfig = "generateServiceConfig" ;
2019-10-10 00:52:42 -04:00
public static readonly string Help = "help" ;
2023-01-18 11:28:43 -05:00
public static readonly string Local = "local" ;
2023-05-11 19:37:56 +03:00
public static readonly string NoDefaultLabels = "no-default-labels" ;
2019-10-10 00:52:42 -04:00
public static readonly string Replace = "replace" ;
2022-01-26 13:23:24 -05:00
public static readonly string DisableUpdate = "disableupdate" ;
2021-09-21 17:31:48 -04:00
public static readonly string Once = "once" ; // Keep this around since customers still relies on it
2019-10-10 00:52:42 -04:00
public static readonly string RunAsService = "runasservice" ;
public static readonly string Unattended = "unattended" ;
public static readonly string Version = "version" ;
}
}
public static class ReturnCode
{
public const int Success = 0 ;
public const int TerminatedError = 1 ;
public const int RetryableError = 2 ;
public const int RunnerUpdating = 3 ;
public const int RunOnceRunnerUpdating = 4 ;
2024-03-27 14:49:58 -04:00
public const int SessionConflict = 5 ;
2025-05-12 16:54:43 -04:00
// Temporary error code to indicate that the runner configuration has been refreshed
// and the runner should be restarted. This is a temporary code and will be removed in the future after
// the runner is migrated to runner admin.
public const int RunnerConfigurationRefreshed = 6 ;
2019-10-10 00:52:42 -04:00
}
2020-04-27 23:44:17 -04:00
2021-01-05 21:49:11 -05:00
public static class Features
{
public static readonly string DiskSpaceWarning = "runner.diskspace.warning" ;
2023-06-14 03:10:53 +02:00
public static readonly string LogTemplateErrorsAsDebugMessages = "DistributedTask.LogTemplateErrorsAsDebugMessages" ;
2022-04-11 14:43:24 +02:00
public static readonly string UseContainerPathForTemplate = "DistributedTask.UseContainerPathForTemplate" ;
2022-09-26 09:20:43 -04:00
public static readonly string AllowRunnerContainerHooks = "DistributedTask.AllowRunnerContainerHooks" ;
2025-05-06 11:45:51 -04:00
public static readonly string AddCheckRunIdToJobContext = "actions_add_check_run_id_to_job_context" ;
2025-05-28 22:46:25 -04:00
public static readonly string DisplayHelpfulActionsDownloadErrors = "actions_display_helpful_actions_download_errors" ;
2025-09-03 11:45:43 -05:00
public static readonly string ContainerActionRunnerTemp = "actions_container_action_runner_temp" ;
2025-10-16 21:16:14 +01:00
public static readonly string SnapshotPreflightHostedRunnerCheck = "actions_snapshot_preflight_hosted_runner_check" ;
public static readonly string SnapshotPreflightImageGenPoolCheck = "actions_snapshot_preflight_image_gen_pool_check" ;
2025-11-07 14:18:52 -06:00
public static readonly string CompareTemplateEvaluator = "actions_runner_compare_template_evaluator" ;
2021-01-05 21:49:11 -05:00
}
2025-08-07 17:30:03 +01:00
// Node version migration related constants
public static class NodeMigration
{
// Node versions
public static readonly string Node20 = "node20" ;
public static readonly string Node24 = "node24" ;
// Environment variables for controlling node version selection
public static readonly string ForceNode24Variable = "FORCE_JAVASCRIPT_ACTIONS_TO_NODE24" ;
public static readonly string AllowUnsecureNodeVersionVariable = "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION" ;
// Feature flags for controlling the migration phases
public static readonly string UseNode24ByDefaultFlag = "actions.runner.usenode24bydefault" ;
public static readonly string RequireNode24Flag = "actions.runner.requirenode24" ;
}
2021-01-05 21:49:11 -05:00
2020-04-27 23:44:17 -04:00
public static readonly string InternalTelemetryIssueDataKey = "_internal_telemetry" ;
2022-12-28 11:56:53 -05:00
public static readonly Guid TelemetryRecordId = new Guid ( "11111111-1111-1111-1111-111111111111" ) ;
2020-04-27 23:44:17 -04:00
public static readonly string WorkerCrash = "WORKER_CRASH" ;
2021-01-05 21:49:11 -05:00
public static readonly string LowDiskSpace = "LOW_DISK_SPACE" ;
2020-10-02 11:34:37 -04:00
public static readonly string UnsupportedCommand = "UNSUPPORTED_COMMAND" ;
2022-12-28 11:56:53 -05:00
public static readonly string ResultsUploadFailure = "RESULTS_UPLOAD_FAILURE" ;
2022-10-04 12:14:22 +01:00
public static readonly string UnsupportedCommandMessage = "The `{0}` command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/" ;
2020-10-02 11:34:37 -04:00
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/" ;
2022-02-24 21:01:49 -05:00
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" ;
2022-12-14 00:28:33 -08:00
public static readonly string SummaryUploadError = "$GITHUB_STEP_SUMMARY upload aborted, an error occurred when uploading the summary. For more information see: https://docs.github.com/actions/using-workflows/workflow-commands-for-github-actions#adding-a-markdown-summary" ;
2019-10-10 00:52:42 -04:00
}
2020-03-02 11:22:45 -05:00
public static class RunnerEvent
{
public static readonly string Register = "register" ;
public static readonly string Remove = "remove" ;
}
2019-10-10 00:52:42 -04:00
public static class Pipeline
{
public static class Path
{
public static readonly string PipelineMappingDirectory = "_PipelineMapping" ;
public static readonly string TrackingConfigFile = "PipelineFolder.json" ;
}
}
public static class Configuration
{
public static readonly string OAuthAccessToken = "OAuthAccessToken" ;
public static readonly string OAuth = "OAuth" ;
}
public static class Expressions
{
public static readonly string Always = "always" ;
public static readonly string Cancelled = "cancelled" ;
public static readonly string Failure = "failure" ;
public static readonly string Success = "success" ;
}
2022-03-18 02:35:04 +01:00
public static class Hooks
{
public static readonly string JobStartedStepName = "Set up runner" ;
public static readonly string JobCompletedStepName = "Complete runner" ;
2022-06-10 15:51:20 +02:00
public static readonly string ContainerHooksPath = "ACTIONS_RUNNER_CONTAINER_HOOKS" ;
2022-03-18 02:35:04 +01:00
}
2019-10-10 00:52:42 -04:00
public static class Path
{
public static readonly string ActionsDirectory = "_actions" ;
2020-01-20 18:22:59 +01:00
public static readonly string ActionManifestYmlFile = "action.yml" ;
public static readonly string ActionManifestYamlFile = "action.yaml" ;
2019-10-10 00:52:42 -04:00
public static readonly string BinDirectory = "bin" ;
public static readonly string DiagDirectory = "_diag" ;
public static readonly string ExternalsDirectory = "externals" ;
public static readonly string RunnerDiagnosticLogPrefix = "Runner_" ;
public static readonly string TempDirectory = "_temp" ;
public static readonly string ToolDirectory = "_tool" ;
public static readonly string UpdateDirectory = "_update" ;
public static readonly string WorkDirectory = "_work" ;
public static readonly string WorkerDiagnosticLogPrefix = "Worker_" ;
}
// Related to definition variables.
public static class Variables
{
public static readonly string MacroPrefix = "$(" ;
public static readonly string MacroSuffix = ")" ;
public static class Actions
{
//
// Keep alphabetical
//
2020-10-02 11:34:37 -04:00
public static readonly string AllowUnsupportedCommands = "ACTIONS_ALLOW_UNSECURE_COMMANDS" ;
2021-09-29 20:44:01 +02:00
public static readonly string AllowUnsupportedStopCommandTokens = "ACTIONS_ALLOW_UNSECURE_STOPCOMMAND_TOKENS" ;
2022-06-09 23:17:11 +02:00
public static readonly string RequireJobContainer = "ACTIONS_RUNNER_REQUIRE_JOB_CONTAINER" ;
2019-10-10 00:52:42 -04:00
public static readonly string RunnerDebug = "ACTIONS_RUNNER_DEBUG" ;
public static readonly string StepDebug = "ACTIONS_STEP_DEBUG" ;
}
2019-12-17 18:21:13 -05:00
public static class Agent
{
public static readonly string ToolsDirectory = "agent.ToolsDirectory" ;
2022-02-14 15:06:08 +01:00
2024-10-16 22:42:43 -04:00
// Set this env var to "nodeXY" to downgrade the node version for internal functions (e.g hashfiles). This does NOT affect the version of node actions.
2022-09-26 09:20:43 -04:00
public static readonly string ForcedInternalNodeVersion = "ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION" ;
public static readonly string ForcedActionsNodeVersion = "ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION" ;
2022-12-06 16:16:00 +01:00
public static readonly string PrintLogToStdout = "ACTIONS_RUNNER_PRINT_LOG_TO_STDOUT" ;
2023-09-28 19:43:55 -04:00
public static readonly string ActionArchiveCacheDirectory = "ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE" ;
2019-12-17 18:21:13 -05:00
}
2019-10-10 00:52:42 -04:00
public static class System
{
//
// Keep alphabetical
//
public static readonly string AccessToken = "system.accessToken" ;
public static readonly string Culture = "system.culture" ;
public static readonly string PhaseDisplayName = "system.phaseDisplayName" ;
2023-05-03 16:04:21 -04:00
public static readonly string JobRequestType = "system.jobRequestType" ;
2023-04-26 15:15:19 -04:00
public static readonly string OrchestrationId = "system.orchestrationId" ;
2019-10-10 00:52:42 -04:00
}
}
2022-09-26 09:20:43 -04:00
public static class OperatingSystem
{
public static readonly int Windows11BuildVersion = 22000 ;
// Both windows 10 and windows 11 share the same Major Version 10, need to use the build version to differentiate
public static readonly int Windows11MajorVersion = 10 ;
}
2019-10-10 00:52:42 -04:00
}
}