首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >我们能在github动作中缓存纱线球体吗?

我们能在github动作中缓存纱线球体吗?
EN

Stack Overflow用户
提问于 2020-05-24 02:04:43
回答 1查看 1.7K关注 0票数 1

我有一些全局包,如无服务器框架、ESLint等等。我已经为纱线实现了GitHub操作缓存。下面是我的密码。

代码语言:javascript
复制
- uses: actions/cache@v1
  id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
  with:
    path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
    key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
    restore-keys: |
      ${{ runner.os }}-yarn-

- name: Adding serverless globally
  run: yarn global add serverless

- name: Yarn Install
  if: steps.yarn-cache.outputs.cache-hit != 'true'              
  run: |
    echo "cache hit failed"
    yarn install
  env:
    CI: false

但我的全球软件包没有缓存。有任何方法来缓存纱全球吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-08-01 12:53:27

我在粘贴解决方案的构建文件,

代码语言:javascript
复制
name: global-test
on:
    push:
        branches:
            - dev
    pull_request:
        branches:
            - dev
jobs:
    aws-deployment:
        runs-on: ubuntu-latest
        steps:
            - name: CHECKOUT ACTION
              uses: actions/checkout@v2

            - name: NODE SETUP ACTION
              uses: actions/setup-node@v1
              with:
                  node-version: '12.x'

            - name: Get yarn cache directory path
              id: yarn-cache-dir-path
              run: |
                  echo "::set-output name=dir::$(yarn cache dir)"

            - name: Set yarn global bin path
              run: |
                  yarn config set prefix $(yarn cache dir)

            - name: Add yarn bin path to system path
              run: |
                  echo $(yarn global bin) >> $GITHUB_PATH

            - name: Set yarn global installation path
              run: |
                  yarn config set global-folder $(yarn cache dir)

            - name: CACHE ACTION
              uses: actions/cache@v2
              env:
                  cache-version: v1
              id: yarn-cache
              with:
                  path: |
                      ${{ steps.yarn-cache-dir-path.outputs.dir }}
                      **/node_modules
                  key: ${{ runner.os }}-yarn-${{ env.cache-version }}-${{ hashFiles('**/yarn.lock') }}
                  restore-keys: |
                      ${{ runner.os }}-yarn-${{ env.cache-version }}-
                      ${{ runner.os }}-yarn-
                      ${{ runner.os }}-

            - name: Installing dependencies
              if: steps.yarn-cache.outputs.cache-hit != 'true'
              run: |
                  echo "YARN CACHE CHANGED"
                  yarn install

            - name: Adding serverless globally
              if: steps.yarn-cache.outputs.cache-hit != 'true'
              run: |
                  echo "NO CACHE HIT"
                  yarn global add serverless

我给台阶起了名字,这样就可以理解它们了。

更新了2020年的答复.12-06

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/61980794

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档