act icon indicating copy to clipboard operation
act copied to clipboard

ACTIONS_RUNTIME_URL, ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL environment variables are missing.

Open quisse opened this issue 6 years ago • 67 comments

Github actions have undocumented environment variables named ACTIONS_RUNTIME_URL, ACTIONS_RUNTIME_TOKEN and ACTIONS_CACHE_URL. The actions/cache action relies on this to create the url to interact with for storing caches. https://github.com/actions/toolkit/blob/1cc56db0ff126f4d65aeb83798852e02a2c180c3/packages/cache/src/internal/cacheHttpClient.ts#L33-L47

They all get populated over here

This is the cause of #285, #169 is linked.

quisse avatar Aug 03 '20 11:08 quisse

Issue is stale and will be closed in 7 days unless there is new activity

github-actions[bot] avatar Nov 25 '20 00:11 github-actions[bot]

The issue is still persistent afaik.

quisse avatar Nov 25 '20 08:11 quisse

Any news about this problem? Came here from #285

DivoK avatar Dec 20 '20 11:12 DivoK

Coming from https://github.com/nektos/act/issues/169

ayozemr avatar Jan 19 '21 16:01 ayozemr

Hi, I'm trying to understand the problem. Are these values dynamically set? Can they be manually set and read by act? If so what to?

jshwi avatar Jan 24 '21 06:01 jshwi

Are these values dynamically set?

@jshwi Those environmental variables are only available to GitHub Actions runners, whether it be runner hosted by GitHub or self-hosted one.

Can they be manually set and read by act?

Probably.

If so what to?

No one knows, if it was that easy it would be fixed already.

Perhaps guys from GitHub (@joshmgross from https://github.com/actions/cache or @TingluoHuang from https://github.com/actions/runner, top committers) could chime in here, maybe give us some clues on how we could solve that issue. I presume it won't be so easy as obtaining and just hardcoding those values since, most likely they are undocumented for a reason and the reason is it's supposed to work only on GitHub Actions service (but please, prove me wrong). There is artefacts API https://docs.github.com/en/rest/reference/actions#artifacts which could be used to replace artefacts actions but I've not found anything regarding cache.

catthehacker avatar Jan 24 '21 12:01 catthehacker

Thank you, @catthehacker. I appreciate now having a better understanding of this.

jshwi avatar Jan 25 '21 03:01 jshwi

👋 @catthehacker is correct, these variables are for internal APIs. If you wanted to manually set these values, you'd also likely need to simulate an internal service to support what these APIs are used for (like caching and artifacts).

joshmgross avatar Jan 25 '21 17:01 joshmgross

@joshmgross Thank you very much for response! 😄 Unfortunately that is what I was afraid of.

So my idea was that act would spin up small http server available to its containers and work as transparent proxy. I might be able to draft something up whenever I get some more free time.

catthehacker avatar Jan 26 '21 07:01 catthehacker

Issue is stale and will be closed in 14 days unless there is new activity

github-actions[bot] avatar Feb 26 '21 00:02 github-actions[bot]

I've built a very quick and simple express server that will simulate the download and upload endpoints of an artifact server here https://github.com/anthonykawa/artifact-server. If you want to use it to help understand building this into act, feel free. It only works if you specify the name and path inputs when uploading and downloading.

anthonykawa avatar Feb 26 '21 01:02 anthonykawa

Thanks a lot @anthonykawa. Will take a look at it soon when I'll get time to develop artefact support.

catthehacker avatar Feb 26 '21 08:02 catthehacker

Issue is stale and will be closed in 14 days unless there is new activity

github-actions[bot] avatar Mar 29 '21 00:03 github-actions[bot]

Needed for artifacts, please don't close

ivan4th avatar Mar 29 '21 15:03 ivan4th

I have built (this year) a whole act like clone which have a builtin artifact and cache server. My clone defines all these variables and is able to use the official self-hosted runners. This source code is incompatible with act, because I used the same language as the official runner to reduce rewriting code and maintenance time. My first goal wasn't to run them locally like act, but on a raspberry pi with a github like server (https://github.com/go-gitea/gitea).

ChristopherHX avatar May 02 '21 12:05 ChristopherHX

I am testing the option from @anthonykawa (PRs incoming) and it seems that act does not properly honor the config:

::debug::Resource Url: localhost:8080_apis/artifactcache/cache?keys=Linux-ubuntu-latest-cargo-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855&version=00e54f95df51f6341273eea43863fcdc3856075880e81a8467ad4870f1a07f31
[Quick check/rust_fmt-1]   💬  ::debug::getCacheEntry - Attempt 1 of 2 failed with error: connect ECONNREFUSED 127.0.0.1:80

I did set an ENV defined as ACTIONS_CACHE_URL=localhost:8080. We can see in the logs that we connect to it ::debug::Resource Url: localhost:8080_ But then suddenly, act complains about :80 not being available...

chevdor avatar Jun 04 '21 16:06 chevdor

@chevdor the runner is running inside docker. I guess the @anthonykawa server is running on your machine, thus localhost refer to docker localhost and not yours. you have to expose the service to make it accessible from inside a container

jgsqware avatar Jul 01 '21 15:07 jgsqware

I'm trying to use @actions/cache in a node script run in a composite steps action, and it does not have these env vars on an ubuntu-latest github-hosted runner. Am I going to be out of luck here, or is there a way to emulate the @actions/cache action manually?

almed4 avatar Jul 08 '21 18:07 almed4

I've built a very quick and simple express server that will simulate the download and upload endpoints of an artifact server here https://github.com/anthonykawa/artifact-server. If you want to use it to help understand building this into act, feel free. It only works if you specify the name and path inputs when uploading and downloading.

Did someone get this up and running in combination with actions/cache@v2? I'm running out of ideas to share Docker images between jobs with Act. Any suggestion?

Erriez avatar Aug 16 '21 17:08 Erriez

Did someone get this up and running in combination with actions/cache@v2?

There is no plan to support that action at all.

I'm running out of ideas to share Docker images between jobs with Act. Any suggestion?

What do you mean? All your images should be stored on your Docker host, there is no need to cache them.

catthehacker avatar Aug 16 '21 17:08 catthehacker