Skip to content

Add ACTIONS_RUNTIME_TOKEN and runtime env vars to ScriptHandler#4325

Open
0b01 wants to merge 2 commits intoactions:mainfrom
0b01:main
Open

Add ACTIONS_RUNTIME_TOKEN and runtime env vars to ScriptHandler#4325
0b01 wants to merge 2 commits intoactions:mainfrom
0b01:main

Conversation

@0b01
Copy link
Copy Markdown

@0b01 0b01 commented Apr 6, 2026

ScriptHandler was missing the Actions Runtime environment variables (ACTIONS_RUNTIME_URL, ACTIONS_RUNTIME_TOKEN, ACTIONS_CACHE_URL, ACTIONS_RESULTS_URL) that NodeScriptActionHandler and ContainerActionHandler already expose. This meant run: steps and hook scripts couldn't interact with Actions runtime services (such as caching, artifacts, etc.) the same way Node/container actions(such as @actions/upload-artifact) can.

Added the same runtime env var block from NodeScriptActionHandler into ScriptHandler, placed before the existing ACTIONS_ID_TOKEN_REQUEST_* setup similar to NodeScriptActionHandler.

Copilot AI and others added 2 commits April 6, 2026 20:50
…ing NodeScriptActionHandler

Agent-Logs-Url: https://github.com/0b01/runner/sessions/e1e389f7-0641-4766-a1e2-29342a652d09

Co-authored-by: 0b01 <1768528+0b01@users.noreply.github.com>
…ailable

Add ACTIONS_RUNTIME_TOKEN and runtime env vars to ScriptHandler
@0b01 0b01 requested a review from a team as a code owner April 6, 2026 20:58
Copilot AI review requested due to automatic review settings April 6, 2026 20:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates ScriptHandler to expose the same GitHub Actions Runtime environment variables that are already provided to Node/container actions, enabling run: steps and hook scripts to call runtime services (cache, artifacts/results, etc.).

Changes:

  • Add ACTIONS_RUNTIME_URL and ACTIONS_RUNTIME_TOKEN to ScriptHandler environment setup.
  • Add optional runtime service URLs (ACTIONS_CACHE_URL, ACTIONS_RESULTS_URL) sourced from SystemVssConnection endpoint data.
  • Align ScriptHandler ordering with other handlers by setting runtime env vars before ACTIONS_ID_TOKEN_REQUEST_*.
Show a summary per file
File Description
src/Runner.Worker/Handlers/ScriptHandler.cs Adds Actions runtime env var injection for script execution environments.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment on lines +314 to +334
// Add Actions Runtime server info
var systemConnection = ExecutionContext.Global.Endpoints.Single(x => string.Equals(x.Name, WellKnownServiceEndpointNames.SystemVssConnection, StringComparison.OrdinalIgnoreCase));
Environment["ACTIONS_RUNTIME_URL"] = systemConnection.Url.AbsoluteUri;
Environment["ACTIONS_RUNTIME_TOKEN"] = systemConnection.Authorization.Parameters[EndpointAuthorizationParameters.AccessToken];
if (systemConnection.Data.TryGetValue("CacheServerUrl", out var cacheUrl) && !string.IsNullOrEmpty(cacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = cacheUrl;
}
if (systemConnection.Data.TryGetValue("PipelinesServiceUrl", out var pipelinesServiceUrl) && !string.IsNullOrEmpty(pipelinesServiceUrl))
{
Environment["ACTIONS_RUNTIME_URL"] = pipelinesServiceUrl;
}
if (systemConnection.Data.TryGetValue("GenerateIdTokenUrl", out var generateIdTokenUrl) && !string.IsNullOrEmpty(generateIdTokenUrl))
{
Environment["ACTIONS_ID_TOKEN_REQUEST_URL"] = generateIdTokenUrl;
Environment["ACTIONS_ID_TOKEN_REQUEST_TOKEN"] = systemConnection.Authorization.Parameters[EndpointAuthorizationParameters.AccessToken];
}
if (systemConnection.Data.TryGetValue("ResultsServiceUrl", out var resultsUrl) && !string.IsNullOrEmpty(resultsUrl))
{
Environment["ACTIONS_RESULTS_URL"] = resultsUrl;
}
Copy link

Copilot AI Apr 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New runtime environment variable injection in ScriptHandler (ACTIONS_RUNTIME_URL/TOKEN/CACHE_URL/RESULTS_URL) changes observable behavior for run: steps and hook scripts, but there are no automated tests covering that these variables are set correctly from SystemVssConnection endpoint data. Please add an L0 test that constructs a ScriptHandler with a mocked ExecutionContext.Global.Endpoints (including CacheServerUrl/PipelinesServiceUrl/ResultsServiceUrl) and asserts the expected Environment entries are populated (and that PipelinesServiceUrl overrides ACTIONS_RUNTIME_URL when present).

Copilot generated this review using guidance from repository custom instructions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants