{"id":14985886,"url":"https://github.com/threeal/cache-action","last_synced_at":"2025-04-11T22:11:49.896Z","repository":{"id":252535020,"uuid":"840633781","full_name":"threeal/cache-action","owner":"threeal","description":"Save and restore files as a cache in GitHub Actions","archived":false,"fork":false,"pushed_at":"2025-04-10T08:57:47.000Z","size":751,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T22:11:44.732Z","etag":null,"topics":["action","actions","cache","cache-control","ci","github-actions"],"latest_commit_sha":null,"homepage":"https://threeal.github.io/cache-action/","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/threeal.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":"2024-08-10T08:04:45.000Z","updated_at":"2025-04-10T08:56:31.000Z","dependencies_parsed_at":"2024-09-05T12:50:05.175Z","dependency_job_id":"e88576e4-7c32-44f9-9f72-9ada3c49ea3d","html_url":"https://github.com/threeal/cache-action","commit_stats":{"total_commits":119,"total_committers":2,"mean_commits":59.5,"dds":0.4201680672268907,"last_synced_commit":"e30fc2146ee29a0b7dcea6dd6c4d4161fac730c2"},"previous_names":["threeal/cache-action"],"tags_count":3,"template":false,"template_full_name":"threeal/action-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fcache-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fcache-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fcache-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fcache-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/threeal","download_url":"https://codeload.github.com/threeal/cache-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248487691,"owners_count":21112190,"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":["action","actions","cache","cache-control","ci","github-actions"],"created_at":"2024-09-24T14:11:50.012Z","updated_at":"2025-04-11T22:11:49.869Z","avatar_url":"https://github.com/threeal.png","language":"TypeScript","readme":"# Cache Action\n\nSave and restore files as a cache in [GitHub Actions](https://github.com/features/actions). Use this project to cache dependencies or build outputs to speed up GitHub Actions workflows.\n\nThis project comprises two components: a GitHub Action that can be used directly in workflows and a [JavaScript](https://developer.mozilla.org/en-US/docs/Web/JavaScript) library that contains functions for use in a [JavaScript Action](https://docs.github.com/en/actions/sharing-automations/creating-actions/creating-a-javascript-action).\n\n## Using the GitHub Action\n\nUse the following snippet to include the action in a GitHub workflow:\n\n```yaml\n- name: Cache Dependencies\n  uses: threeal/cache-action@v0.3.0\n  with:\n    key: a-key\n    version: a-version\n    files: a-file another-file\n```\n\nBy default, the action will attempt to restore files from a cache if it exists; otherwise, it will save files to a cache at the end of the workflow run.\n\nTo restore and save the cache in separate steps, refer to the [restore](https://github.com/threeal/cache-action/tree/v0.3.0/restore) and [save](https://github.com/threeal/cache-action/tree/v0.3.0/save) sub-actions.\n\n### Available Inputs\n\n| Name      | Value Type       | Description                                              |\n| --------- | ---------------- | -------------------------------------------------------- |\n| `key`     | String           | The cache key.                                           |\n| `version` | String           | The cache version.                                       |\n| `files`   | Multiple Strings | The files to be cached, separated by spaces or newlines. |\n\n### Available Outputs\n\n| Name       | Value Type        | Description                                                             |\n| ---------- | ----------------- | ----------------------------------------------------------------------- |\n| `restored` | `true` or `false` | A boolean value indicating whether the cache was successfully restored. |\n\n### Example Usage\n\nThe following example demonstrates how to use the action to cache [Node.js](https://nodejs.org/) dependencies in a GitHub Action workflow:\n\n```yaml\nname: Build\non:\n  push:\njobs:\n  build-project:\n    name: Build Project\n    runs-on: ubuntu-24.04\n    steps:\n      - name: Checkout Project\n        uses: actions/checkout@v4.2.2\n\n      - name: Cache Dependencies\n        id: cache-deps\n        uses: threeal/cache-action@v0.3.0\n        with:\n          key: node-deps\n          version: ${{ hashFiles('package-lock.json') }}\n          files: node_modules\n\n      - name: Install Dependencies\n        if: steps.cache-deps.outputs.restored == 'false'\n        run: npm install\n\n      # Do something\n```\n\nThis action will attempt to restore a cache with the key `node-deps` and a version specified by the hash of the `package-lock.json` file. If the cache exists, it will restore the `node_modules` directory and skip dependency installation. Otherwise, it will install the dependencies and save the `node_modules` to the cache at the end of the workflow run.\n\n## Using the JavaScript Library\n\nInstall the JavaScript library using a package manager:\n\n```bash\nnpm install cache-action\n```\n\nImport the functions using the import statement:\n\n```js\nimport { restoreCache, saveCache } from \"cache-action\";\n\nconst restored = await restoreCache(\"a-key\", \"a-version\");\nif (!restored) {\n  // Do something...\n\n  await saveCache(\"a-key\", \"a-version\", [\"a-file\", \"another-file\"]);\n}\n```\n\nThe library provides two functions: `restoreCache` for restoring files from a cache and `saveCache` for saving files to a cache. Refer to the library documentation [here](https://threeal.github.io/cache-action/modules.html) for more details on function usage.\n\n## License\n\nThis project is licensed under the terms of the [MIT License](./LICENSE).\n\nCopyright © 2024-2025 [Alfi Maulana](https://github.com/threeal)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeal%2Fcache-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreeal%2Fcache-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeal%2Fcache-action/lists"}