default.gitlab-ci.yml 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. # 定义 stages
  2. stages:
  3. - install
  4. - build
  5. - deploy
  6. # 每个job之前运行的命令
  7. before_script:
  8. - whoami
  9. - pwd
  10. cache:
  11. key: ${CI_BUILD_REF_NAME}
  12. paths:
  13. - node_modules/ # 为node_modules增加缓存
  14. install:
  15. stage: install
  16. script:
  17. - echo "======= 开始 安装依赖 ======="
  18. - npm install
  19. # 可以切换为淘宝镜像
  20. # - npm --registry https://registry.npm.taobao.org install express
  21. - echo "======= 完成 安装依赖 ======="
  22. only:
  23. - master
  24. when: manual
  25. build:
  26. stage: build
  27. script:
  28. - echo "======= 开始 构建 ======="
  29. - npm run build:p
  30. - echo "======= 结束 构建 ======="
  31. artifacts:
  32. expire_in: 1 week # 生成文件保存周期
  33. name: '${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}'
  34. paths:
  35. - dist # 编译后生成的文件夹名
  36. only:
  37. - master
  38. deploy:
  39. stage: deploy
  40. script:
  41. - echo "======= 开始 部署 ======="
  42. - npm run qiniu
  43. - npm run deploy
  44. - echo "======= 完成 部署 ======="
  45. when: manual
  46. only:
  47. - master