Skip to content

sp-ricard-valverde/github-act-cache-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

31 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-act-cache-server

Spin up a local Github artifact cache server to be used with act Github actions that uses actions/cache

Run

Set the environment variable for your authorization key (current terminal session only)

  • Linux & Mac: export ACT_CACHE_AUTH_KEY=foo
  • Windows Powershell: $env:ACT_CACHE_AUTH_KEY = 'foo'
  • Windows CMD: setx ACT_CACHE_AUTH_KEY foo

Or set the environment variable permanently

Start the Docker container

docker compose up --build

Act config

Ensure you add the following configuration to your ~/.actrc file:

--env ACTIONS_CACHE_URL=http://127.0.0.1:8080/
--env ACTIONS_RUNTIME_URL=http://127.0.0.1:8080/
--env ACTIONS_RUNTIME_TOKEN=foo

Observations

  • You can set ACT_CACHE_AUTH_KEY and ACTIONS_RUNTIME_TOKEN to the value you want, but they must be the same
  • The cache is persisted in Docker's named volumes(when using docker-compose) so it will survive between containers
  • To purge the cache use the endpoint /_apis/artifactcache/clean. ie
    • Linux & Mac: curl -X POST -H 'Authorization: Bearer foo' 'http://127.0.0.1:8080/_apis/artifactcache/clean'
    • Windows Powershell: Invoke-WebRequest -Method POST -Headers @{"Authorization"="Bearer foo"} -Uri "http://127.0.0.1:8080/_apis/artifactcache/clean"
    • Windows CMD: curl -X POST -H "Authorization: Bearer foo" "http://127.0.0.1:8080/_apis/artifactcache/clean"

Caveats

  • The caching is global, meaning that it's shared across git projects and branches. As the container lacks the information of the Github context the action is running on it does not have access to GITHUB_REPOSITORY, GITHUB_REF or GITHUB_BASE_REF so it can do a better job restoring fallback caches or switching branches

Acknowledgments

About

Github artifact cache server to be used locally

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published