version: '1.0'
name: pipeline-admin
displayName: pipeline-admin
triggers:
  trigger: auto
  push:
    branches:
      prefix:
        - dev
stages:
  - name: stage-c475b4e4
    displayName: 前端打包
    strategy: naturally
    trigger: auto
    executor: []
    steps:
      - step: build@nodejs
        name: build_nodejs
        displayName: Nodejs 构建
        nodeVersion: 21.5.0
        commands:
          - '# 设置NPM源，提升安装速度'
          - npm config set registry https://registry.npmmirror.com
          - npm i -g pnpm
          - cd admin
          - '# 执行编译命令'
          - pnpm i
          - pnpm run prod
        artifacts:
          - name: BUILD_Admin
            path:
              - ./admin/dist
        caches:
          - ~/.npm
          - ~/.yarn
          - ~/.pnpm-store
        notify: []
        strategy:
          retry: '0'
      - step: deploy@agent
        name: deploy_admin
        displayName: 主机部署
        hostGroupID:
          ID: tengxun_qingliang
          hostID:
            - fee90b81-14b8-4170-915d-3da3f413a812
        deployArtifact:
          - source: build
            name: admin
            target: ~/gitee_go/deploy
            dependArtifact: BUILD_Admin
        script:
          - '# 功能：部署脚本会在部署主机组的每台机器上执行'
          - '# 使用场景：先将制品包解压缩到指定目录中，再执行启动脚本deploy.sh，脚本示例地址：https://gitee.com/gitee-go/spring-boot-maven-deploy-case/blob/master/deploy.sh'
          - mkdir -p /www/wwwroot/likeadmin/web
          - tar zxvf ~/gitee_go/deploy/admin.tar.gz -C /www/wwwroot/likeadmin/web
          - ''
          - echo '后台前端部署完成'
        notify: []
        strategy:
          retry: '0'
        dependsOn: build_nodejs
