{"id":13531327,"url":"https://github.com/c-hive/gha-yarn-cache","last_synced_at":"2025-04-01T19:31:59.106Z","repository":{"id":42829835,"uuid":"265936247","full_name":"c-hive/gha-yarn-cache","owner":"c-hive","description":"1-liner yarn install cache for GitHub Actions","archived":true,"fork":false,"pushed_at":"2022-08-13T11:38:58.000Z","size":79,"stargazers_count":91,"open_issues_count":0,"forks_count":15,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-19T16:18:29.363Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/c-hive.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}},"created_at":"2020-05-21T19:39:06.000Z","updated_at":"2024-08-29T11:38:03.000Z","dependencies_parsed_at":"2023-01-05T05:02:14.591Z","dependency_job_id":null,"html_url":"https://github.com/c-hive/gha-yarn-cache","commit_stats":{"total_commits":25,"total_committers":6,"mean_commits":4.166666666666667,"dds":0.64,"last_synced_commit":"e1c52e93639a0b17bd9098e96a86be4227e22805"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":"c-hive/js-boilerplate","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-hive%2Fgha-yarn-cache","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-hive%2Fgha-yarn-cache/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-hive%2Fgha-yarn-cache/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/c-hive%2Fgha-yarn-cache/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/c-hive","download_url":"https://codeload.github.com/c-hive/gha-yarn-cache/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246700546,"owners_count":20819895,"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":[],"created_at":"2024-08-01T07:01:02.068Z","updated_at":"2025-04-01T19:31:54.097Z","avatar_url":"https://github.com/c-hive.png","language":"JavaScript","funding_links":[],"categories":["Community Resources","JavaScript","五、按场景分类的实用Action"],"sub_categories":["Utility","1. 依赖管理（提速+合规）"],"readme":"## Deprecated\n\nThis functionality is now part of [`actions/setup-node`](https://github.com/actions/setup-node):\n\n```yml\n- name: Setup Node.js\n  uses: actions/setup-node@v3\n  with:\n    node-version: '16'\n    cache: 'yarn'\n```\n\n---\n\n# gha-yarn-cache\n\n#### 1-liner yarn install cache for GitHub Actions\n\nStatus and support\n\n- \u0026#x2714; stable\n- \u0026#x2714; supported\n- \u0026#x2716; no ongoing development\n\n[![CI](/../../workflows/CI/badge.svg?branch=master)](/../../actions)\n\nGitHub Action caches improve build times and reduce network dependencies. However, writing the correct cache logic is [tricky](https://github.com/actions/cache/blob/9ab95382c899bf0953a0c6c1374373fc40456ffe/examples.md#node---yarn). You need to understand how the [cache action](https://github.com/actions/cache) (keys and restore keys) work. Did you know you're not supposed to cache the `node_modules` folder? The setup is different per OS and takes a lot of space in your workflows. Not anymore!\n\n`gha-yarn-cache` is a simple 1-liner that covers all use-cases, correctly:\n- Caches the Yarn cache directory instead of `node-modules` [as recommended](https://github.com/actions/cache/blob/9ab95382c899bf0953a0c6c1374373fc40456ffe/examples.md#node---yarn)\n- Works on Ubuntu, MacOS and Windows\n- Restore keys take the OS into account [as recommended](https://github.com/actions/cache/blob/9ab95382c899bf0953a0c6c1374373fc40456ffe/examples.md#node---yarn)\n- Builds on the [native cache functionality of GitHub Actions](https://github.com/actions/toolkit/tree/master/packages/cache), same as [v2 of the generic cache action](https://github.com/actions/cache/issues/55#issuecomment-629433225)\n\n## Usage\n\nAdd this step before `yarn install`:\n```yml\nuses: c-hive/gha-yarn-cache@v2\n```\n\nFor example:\n\n`.github/workflows/ci.yml`\n```yml\nname: CI\n\non: [push]\n\njobs:\n  lint:\n    runs-on: ubuntu-latest\n    steps:\n    - uses: actions/checkout@v1\n\n    - uses: c-hive/gha-yarn-cache@v2\n      # with:\n        # directory: server # Optional, speficy the folder of yarn.lock if not in the root directory\n\n    - name: Install JS dependencies\n      run: yarn install\n    - name: Test\n      run: yarn test\n```\n\n### Solution comparison\n\n[Native](https://github.com/actions/cache/blob/9ab95382c899bf0953a0c6c1374373fc40456ffe/examples.md#node---yarn)\n```yml\n- name: Get yarn cache directory path\n  id: yarn-cache-dir-path\n  run: echo \"::set-output name=dir::$(yarn cache dir)\"\n\n- uses: actions/cache@v1\n  id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)\n  with:\n    path: ${{ steps.yarn-cache-dir-path.outputs.dir }}\n    key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}\n    restore-keys: |\n      ${{ runner.os }}-yarn-\n```\n\n`gha-yarn-cache`\n```yml\n- uses: c-hive/gha-yarn-cache@v2\n```\n\n## Conventions\n\nThis project follows [C-Hive guides](https://github.com/c-hive/guides) for code style, way of working and other development concerns.\n\n## License\n\nThe project is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-hive%2Fgha-yarn-cache","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fc-hive%2Fgha-yarn-cache","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fc-hive%2Fgha-yarn-cache/lists"}