首页 > 解决方案 > Github 操作如何仅进行 1 次 npm 安装

问题描述

我正在使用 GitHub 操作进行部署。而且我每次推送时都需要构建 vuejs 应用程序。现在一切正常,但每次我花几分钟时间安装 npm。

我可以安装 1 次模块,而不是在每次部署后重新安装吗?

on: push
name:  Deploy website on push
jobs:
  web-deploy:
    name:  Deploy
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [15.x]
    steps:

    - name:  Get latest code
      uses: actions/checkout@v2.3.2

    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ matrix.node-version }}

    - run: npm install --legacy-peer-deps     
    - run: npm run build    
    
    - name:  Sync files
      uses: SamKirkland/FTP-Deploy-Action@4.0.0
      with:
        server: ${{ secrets.host}}
        username: ${{ secrets.user}}
        password: ${{ secrets.pass }}
        local-dir: dist/
        dangerous-clean-slate: true
    

标签: githubgithub-actions

解决方案


推荐阅读