Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to overwrite ACTIONS_CACHE_URL environment variable #3411

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Allow to overwrite ACTIONS_CACHE_URL environment variable
The runner script sets the `ACTIONS_CACHE_URL` using the value from the
system connection. Currently, there's no way to override it.

Some community users use custom cache solutions with self-hosted
runners. They need to maintain a fork of `actions/runner` or
`actions/toolkit`, and `actions/cache` to override the value in their
solution. However it leads to significant maintenance work.

If the runner script allows the `ACTIONS_CACHE_URL` value to be
overridden by the `CUSTOM_ACTIONS_CACHE_URL` environment variable, it
makes life a lot easier for the community, includes myself.

An alternative solution could involve allowing the base URL value in
`actions/toolkit` to be overridden. Several individuals have submitted
similar PRs to this one actions/toolkit#1695,
but they have not received adequate attention from the maintainers.
  • Loading branch information
enescakir committed Dec 4, 2024
commit f25bf839c4c852703e55aba52aaa1da0d3a6aa4e
8 changes: 7 additions & 1 deletion src/Runner.Worker/Handlers/ContainerActionHandler.cs
Original file line number Diff line number Diff line change
@@ -219,7 +219,13 @@ public async Task RunAsync(ActionRunStage stage)
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))

string customCacheUrl = System.Environment.GetEnvironmentVariable("CUSTOM_ACTIONS_CACHE_URL");
if (!string.IsNullOrEmpty(customCacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = customCacheUrl;
}
else if (systemConnection.Data.TryGetValue("CacheServerUrl", out var cacheUrl) && !string.IsNullOrEmpty(cacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = cacheUrl;
}
8 changes: 7 additions & 1 deletion src/Runner.Worker/Handlers/NodeScriptActionHandler.cs
Original file line number Diff line number Diff line change
@@ -54,7 +54,13 @@ public async Task RunAsync(ActionRunStage stage)
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))

string customCacheUrl = System.Environment.GetEnvironmentVariable("CUSTOM_ACTIONS_CACHE_URL");
if (!string.IsNullOrEmpty(customCacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = customCacheUrl;
}
else if (systemConnection.Data.TryGetValue("CacheServerUrl", out var cacheUrl) && !string.IsNullOrEmpty(cacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = cacheUrl;
}