Container action is missing ACTIONS_RESULTS_URL
Hello,
As we patch the binary for ACTIONS_RESULTS_URL, the container action are missing the ACTIONS_RESULTS_URL variable.
I had this error in actions/upload step:
Error: Unable to get the ACTIONS_RESULTS_URL env variable
Here is the test I've setup: https://github.com/saez0pub/testing-self-hosted-cache
I ended up to patch the runner and rebuild it.
diff --git a/src/Runner.Worker/Handlers/ContainerActionHandler.cs b/src/Runner.Worker/Handlers/ContainerActionHandler.cs
index 775ce2f0..0d306016 100644
--- a/src/Runner.Worker/Handlers/ContainerActionHandler.cs
+++ b/src/Runner.Worker/Handlers/ContainerActionHandler.cs
@@ -219,7 +219,12 @@ namespace GitHub.Runner.Worker.Handlers
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 customActionCacheUrl = System.Environment.GetEnvironmentVariable("CUSTOM_ACTIONS_CACHE_URL");
+ string customActionsResultsUrl = System.Environment.GetEnvironmentVariable("CUSTOM_ACTIONS_RESULTS_URL");
+ if (!string.IsNullOrEmpty(customActionCacheUrl))
+ {
+ Environment["ACTIONS_CACHE_URL"] = customActionCacheUrl;
+ } else if (systemConnection.Data.TryGetValue("CacheServerUrl", out var cacheUrl) && !string.IsNullOrEmpty(cacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = cacheUrl;
}
@@ -232,7 +237,10 @@ namespace GitHub.Runner.Worker.Handlers
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))
+ if (!string.IsNullOrEmpty(customActionsResultsUrl))
+ {
+ Environment["ACTIONS_RESULTS_URL"] = customActionsResultsUrl;
+ } else if (systemConnection.Data.TryGetValue("ResultsServiceUrl", out var resultsUrl) && !string.IsNullOrEmpty(resultsUrl))
{
Environment["ACTIONS_RESULTS_URL"] = resultsUrl;
}
diff --git a/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs b/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs
index a399f13d..7106d144 100644
--- a/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs
+++ b/src/Runner.Worker/Handlers/NodeScriptActionHandler.cs
@@ -54,7 +54,12 @@ namespace GitHub.Runner.Worker.Handlers
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 customActionCacheUrl = System.Environment.GetEnvironmentVariable("CUSTOM_ACTIONS_CACHE_URL");
+ string customActionsResultsUrl = System.Environment.GetEnvironmentVariable("CUSTOM_ACTIONS_RESULTS_URL");
+ if (!string.IsNullOrEmpty(customActionCacheUrl))
+ {
+ Environment["ACTIONS_CACHE_URL"] = customActionCacheUrl;
+ } else if (systemConnection.Data.TryGetValue("CacheServerUrl", out var cacheUrl) && !string.IsNullOrEmpty(cacheUrl))
{
Environment["ACTIONS_CACHE_URL"] = cacheUrl;
}
@@ -67,7 +72,10 @@ namespace GitHub.Runner.Worker.Handlers
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))
+ if (!string.IsNullOrEmpty(customActionsResultsUrl))
+ {
+ Environment["ACTIONS_RESULTS_URL"] = customActionsResultsUrl;
+ } else if (systemConnection.Data.TryGetValue("ResultsServiceUrl", out var resultsUrl) && !string.IsNullOrEmpty(resultsUrl))
{
Environment["ACTIONS_RESULTS_URL"] = resultsUrl;
}
And using these variables:
CUSTOM_ACTIONS_CACHE_URL=http://yourip:3000/
CUSTOM_ACTIONS_RESULTS_URL=http://yourip:3000/
I just faced similar issue when switched to local cache for github runners. Any plans to fix that without recompiling the code?
I currently don't see a way other than compiling a patched version of the runner. Maybe we could provide a drop-in replacement runner binary with the mentioned patches so you don't have to compile your own?
Feel free to share any other ideas. 🙏
I like the idea of having drop in replacement!
You can check out the image here https://github.com/falcondev-oss/runner/pkgs/container/actions-runner
use CUSTOM_ACTIONS_RESULTS_URL
I will try to verify that image today. Should I only configure one variable CUSTOM_ACTIONS_RESULTS_URL or both variablesCUSTOM_ACTIONS_RESULTS_URL and CUSTOM_ACTIONS_CACHE_URL?
only CUSTOM_ACTIONS_RESULTS_URL, ACTIONS_CACHE_URL is not used anymore if you're not using old cache actions
Ok. I was able to setup simple workflow and confirmed that in both cases everything is working. Pure ubuntu runner and runner with node container are successful. Now I need to figured out how to use your runner as I am already using my custom base image that use latest ubuntu 24 plus few other packages that are useful for our builds:
# workarround: https://github.com/actions/runner/issues/3623
sed -i 's/8.0-jammy/9.0-noble/g' runner-${{ github.event.inputs.github_runner_version }}/images/Dockerfile
sed -i 's/ubuntu22/ubuntu24/g' runner-${{ github.event.inputs.github_runner_version }}/images/Dockerfile
are you able to publish runner.tar.gz as well?
https://github.com/falcondev-oss/runner/releases/tag/v2.324.0
That appears to have worked until Github released 2.235.0. Watching my @falcondev-oss/runners immediately update themselves on boot and (apparently) lose the override and revert to github centralized caching.
You need to disable auto update when using the cache server. Freeze the runner image and manually update.