{"id":17948492,"url":"https://github.com/dhadka/ezcache","last_synced_at":"2025-03-24T22:35:28.250Z","repository":{"id":42047271,"uuid":"306655184","full_name":"dhadka/ezcache","owner":"dhadka","description":"Easy to use caching for GitHub Actions","archived":false,"fork":false,"pushed_at":"2023-08-14T17:44:53.000Z","size":1339,"stargazers_count":7,"open_issues_count":7,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T09:05:00.669Z","etag":null,"topics":["actions","cache"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhadka.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-10-23T14:05:49.000Z","updated_at":"2024-03-27T13:07:04.000Z","dependencies_parsed_at":"2024-10-29T09:15:12.566Z","dependency_job_id":null,"html_url":"https://github.com/dhadka/ezcache","commit_stats":{"total_commits":97,"total_committers":2,"mean_commits":48.5,"dds":"0.25773195876288657","last_synced_commit":"fbdfe534a866118bf76138a06d602176c76be706"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhadka%2Fezcache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhadka%2Fezcache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhadka%2Fezcache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhadka%2Fezcache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhadka","download_url":"https://codeload.github.com/dhadka/ezcache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245366205,"owners_count":20603438,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","cache"],"created_at":"2024-10-29T09:04:59.357Z","updated_at":"2025-03-24T22:35:23.238Z","avatar_url":"https://github.com/dhadka.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ezcache\n\n![Tests](https://github.com/dhadka/ezcache/workflows/Tests/badge.svg) ![Publish Actions](https://github.com/dhadka/ezcache/workflows/Publish%20Actions/badge.svg)\n\nCaching made easy.  Based on the [GitHub Actions Cache](http://github.com/actions/cache), this action simplifies\nthe process of setting up the cache by providing predefined configurations for different languages and package\nmanagement tools.  Here's a few simple examples:\n\n1. Auto-detect and create the appropriate cache(s) for your repo:\n\n   ```\n   - uses: dhadka/ezcache@master\n   ```\n   \n2. Explicitly configure the cache type:\n\n   ```\n   - uses: dhadka/ezcache@master\n     with:\n       type: npm\n   ```\n\n3. [Separate save and restore steps](#explicit-save-and-restore-steps) for even more control:\n\n   ```\n   - uses: dhadka/ezcache-restore@master\n   ...\n   - uses: dhadka/ezcache-save@master\n   ```\n   \n4. Different [backend storage providers](#storage-providers), including hosted, local, Azure, and AWS S3.  Use local\n   or S3 to cache content of self-hosted runners and GitHub Enterprise Server!\n\n   ```\n   - uses: dhadka/ezcache@master\n     with:\n       type: npm\n       provider: local\n   ```\n\n## Supported Languages\n\nezcache recognizes the following programming languages and package management tools.  If you do\nnot explicitly specify the `type`, ezcache will attempt to auto-detect the appropriate type\n(or types) for your repository.\n\n| Language | Package Manager    | Type        |\n| -------- | ------------------ | ----------- |\n| C#       | Nuget              | `nuget`     |\n| D        | Dub                | `dub`       |\n| Elixir   | Mix                | `mix`       |\n| Erlang   | Rebar3             | `rebar3`    |\n| Go       |                    | `go`        |\n| Java     | Gradle             | `gradle`    |\n| Java     | Maven              | `maven`     |\n| Node     | NPM                | `npm`       |\n| Node     | Yarn               | `yarn`      |\n| PHP      | Composer           | `composer`  |\n| Python   | Pip                | `pip`       |\n| Python   | Virtual Env w/ Pip | `pipenv`    |\n| Python   | Poetry             | `poetry`    |\n| R        |                    | `renv`      | \n| Ruby     | Bundler            | `bundler`   |\n| Rust     | Cargo              | `cargo`     |\n| Scala    | SBT                | `sbt`       |\n| Swift / Obj-C | Carthage      | `carthage`  |\n| Swift / Obj-C | Cocoapods     | `cocoapods` |\n| Swfit    | Mint               | `mint`      |\n| Swift    | SPM                | `spm`       |\n\n## Powershell Cache\n\nThe `powershell` cache will not only cache the specified modules but will also\nautomatically install them during a cache miss.\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: powershell\n    modules: SqlServer, PSScriptAnalyzer\n```\n\n## General-Purpose Caches\n\nezcache also supports a number of general-purpose cache types.  Each will store one or more paths.  Put\neach path on a separate line.\n\n### daily\n\nCreates a cache that is updated once a day.  This is useful when caching content that changes frequently,\nbut we don't want to create new caches after every change.  For example, this could be used to cache the\n`.git` folder for a large repo, where a full checkout is slow but pulling new changes is relatively fast:\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: daily\n    path: .git\n- uses: actions/checkout@v2\n```\n\n### weekly\n\nSimilar to `daily` except, you guessed it, updates once a week.\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: weekly\n    path: .git\n- uses: actions/checkout@v2\n```\n\n### diff\n\nCreates a cache that is updated whenever the folder contents change.\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: diff\n    path: ~/path/to/cache\n```\n\n### script\n\nCreates a cache based off an installation script.  Changes to the script will trigger a cache miss.\nDuring a cache miss, the updated script will be invoked and a new cache created.\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: script\n    script: ./install-dependencies.sh\n    path: ~/path/to/dependencies\n```\n\n### env\n\nCreates a cache that is updated only when the `UPDATE_CACHE` environment variable is set to `true`.\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: env\n    path: ~/path/to/cache\n- name: Install dependencies\n  run: |\n    INSTALLED_VERSION=...\n    LATEST_VERSION=...\n    if [[ INSTALLED_VERSION != LATEST_VERSION ]]; then\n      ...install new version...\n      echo \"UPDATE_CACHE=true\" \u003e\u003e $GITHUB_ENV\n    fi\n```\n\n### run\n\nCreates a new cache for every run of your workflow.  This can be used to share data between different jobs\nin a workflow.  Please use this with caution as caches can be evicted at any time, potentially leading to\nfailing restores.\n\nTip: Use the [needs](https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idneeds)\nfield to ensure jobs that read the cache run after the job that create the cache.\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: run\n    path: ~/path/to/cache\n```\n\n## Docker Caches\n\n### Build Layers\n\nCaches each Docker layer found on the runner (excluding any that previously existed on the runner) to improve build times.\nThis was originally developed by [satackey/action-docker-layer-caching](https://github.com/satackey/action-docker-layer-caching).\n\n```\n- name: Cache docker layers\n  uses: dhadka/ezcache@master\n  with:\n    type: layers\n```\n\n### BuildX\n\nCaches build artifacts from Docker's BuildX.  This works by specifying the `--cache-from` and `--cache-to` options\nused by BuildX:\n\n```\n- name: Set up Docker Buildx\n  uses: docker/setup-buildx-action@v1\n  with:\n    version: latest\n\n- name: Cache Buildx\n  uses: dhadka/ezcache@master\n  with:\n    type: buildx\n    path: /tmp/.buildx-cache\n\n- name: Docker Buildx (build)\n  run: |\n    docker buildx build \\\n      --cache-from \"type=local,src=/tmp/.buildx-cache\" \\\n      --cache-to \"type=local,dest=/tmp/.buildx-cache\" \\\n      --platform linux/386 \\\n      --output \"type=image,push=false\" \\\n      --tag myimage:latest \\\n      --file ./Dockerfile ./\n```\n\n## Handling Cache Misses\n\nCache misses should be expected and handled by the workflow.  There are two types of cache misses:\n\n1. A **miss** where no matching cache was found\n2. A **partial hit** where some of the cache contents are restored\n\nIn both cases, this action will output `cache-hit` set to `false`.  You can then conditionally run \nany steps to install the remaining dependencies:\n\n```\n- name: Install dependencies\n  if: steps.cache.outputs.cache-hit != 'true'\n  run: ...\n```\n\n## Versioning\n\nCaches can also be versioned by specifying the `version` input, for example:\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: npm\n    version: v2\n```\n\nThe version can be any arbitrary string and is useful when needing to \"clear\" the cache contents.  This would\nnormally require you to make a commit to change the version, but an alternative is to use a secret value:\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: npm\n    version: ${{ secrets.CACHE_VERSION }}\n```\n\nIf the cache is ever corrupted, you can \"clear\" the cache by quickly changing the value in the secret.\n\n## Storage Providers\n\nBy default, `hosted` storage is used which is backed by the GitHub Actions Cache servers.  As such, the same\n[usage limits and eviction policy](https://docs.github.com/en/free-pro-team@latest/actions/guides/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy) applies.  You can also use one of these\nalternative storage providers.  Please refer to the [storage provider docs](src/providers/README.md) for additional\ninformation and known issues.\n\n### `local`\n\nStores caches on the local file system.  Because of this, jobs can only save to and restore caches created on the \nmachine processing the job.\n\n:warning: Using the local cache to pass data between jobs might not work if there are multiple runners, as each job can run\non a different machine.  Local storage will also not work on hosted runners. :warning:\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: npm\n    provider: local\n```\n\n### `s3`\n\nUses the AWS CLI that is installed on hosted runners (or [needs to be installed](https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html)\non self-hosted runners) to save and restore cache content to an S3 bucket. \n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: npm\n    provider: s3\n  env:\n    AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}\n    AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}\n    AWS_BUCKET_NAME: ${{ secrets.AWS_BUCKET_NAME }}\n    AWS_REGION: us-east-1\n```\n\nTo use with an S3 compatible provider, such as Minio, set the AWS_ENDPOINT env var to the appropriate address.\n\n### `azure`\n\nUses the Azure CLI (`az`) that is installed on hosted runners (or [needs to be installed](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli)\non self-hosted runners) to save and restore cache content to an Azure storage account.\n\n```\n- uses: dhadka/ezcache@master\n  with:\n    type: npm\n    provider: azure\n  env:\n    SAS_TOKEN: ${{ secrets.SAS_TOKEN }}\n    ACCOUNT_NAME: ${{ secrets.ACCOUNT_NAME }}\n    CONTAINER_NAME: cache\n```\n\nThis supports authentication through the `SAS_TOKEN`, `CONNECTION_STRING`, or `ACCOUNT_KEY` env vars.\n\n# Explicit Save and Restore Steps\n\nBy default, caches are saved at the end of a workflow, in the so called \"post step\".  This post step is only\nexecuted when all steps in the workflow are successful.  If you need more control over when to save the cache,\nyou can call the restore and save operations explicitly:\n\n```\n- uses: dhadka/ezcache-restore@master\n  with:\n    type: npm\n\n...\n\n- uses: dhadka/ezcache-save@master\n  with:\n    type: npm\n```\n\n# Contributing\n\nWant to add support for a new language or tool?  Great!  The caching logic for each language / tool is contained\nwithin a \"handler\", which are located in [src/handlers](src/handlers).  Once you have written your handler, register\nit inside [src/handlers/all.ts](src/handlers/all.ts).\n\nOnce your contribution is ready and tested:\n1. Run `npm run build`\n2. Add, commit, and push your changes\n3. Create a pull request so it can be reviewed\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhadka%2Fezcache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhadka%2Fezcache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhadka%2Fezcache/lists"}