image: node:14.17.1 before_script: - echo '====== 准备构建中 =========' stages: - install - lint - build - deploy ### 配置缓存 cache: key: files: - package.json - packages/ghost-weapp-ui/package.json paths: - node_modules/ - packages/ghost-weapp-ui/node_modules/ ### 直接缓存.npm,.npm中缓存了所有依赖,因为gitlab缓存是分项目的,所以两种方法个人觉得没有什么区别 # - .npm/ # eslint检测 job_lint: only: - master stage: lint before_script: - echo 'eslint检测' - ls -a script: - cd packages/ghost-weapp-ui - ls -a - yarn lint - echo 'eslint检测完成' retry: 0 when: 'on_success' # 安装依赖 job_install: only: - master stage: install before_script: - echo '安装依赖' script: - yarn config set registry https://registry.npm.taobao.org/ - yarn install - cd packages/ghost-weapp-ui - ls -a - yarn install - ls -a - echo '依赖安装完成' retry: 0 # 打包编译 job_build: only: - master stage: build before_script: - echo '开始打包' script: - cd packages/ghost-weapp-ui - ls -a - yarn - ls -a - yarn build - echo '构建完成' when: 'on_success' retry: 0 # 发布 job_deploy: only: - master stage: deploy before_script: - echo '更新补丁版本,准备发布' script: - cd packages/ghost-weapp-ui - node deploy.js ${CI_COMMIT_REF_NAME} when: 'on_success' retry: 0 after_script: - echo "====== 发布完成 ========="