.gitlab-ci.yml 897 Bytes
Newer Older
zhaoxuanchao's avatar
zhaoxuanchao committed
1
default:
zhaoxuanchao's avatar
zhaoxuanchao committed
2
  image: node:12
zhaoxuanchao's avatar
zhaoxuanchao committed
3 4 5 6 7

stages:
  - build
  - test
  - deploy
zhaoxuanchao's avatar
zhaoxuanchao committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36

.build_code:
  stage: build
  script:
    - ping mirrors.aliyun.com -c 5
    - ping registry.npm.taobao.org -c 5
    - yarn bootstrap
    - yarn run build
  artifacts:
    name: "${CI_COMMIT_SHA}_build"
    untracked: true
    paths:
      - build/
    expire_in: 3 hrs

.upload_to_server:
  stage: deploy
  script:
    # 换源aliyun并安装rsync
    - sed -i "s@deb.debian.org@mirrors.aliyun.com@g" /etc/apt/sources.list
    - sed -i "s@security.debian.org@mirrors.aliyun.com@g" /etc/apt/sources.list
    - DEBIAN_FRONTEND=noninteractive && apt-get clean && apt-get update --fix-missing && apt-get install -y rsync
    # 配置ssh密钥和config
    - mkdir -p ~/.ssh
    - cp ${FRONTEND_SSH_KEY} ~/.ssh/id_rsa
    - chmod 700 ~/.ssh/id_rsa
    - cp ${FRONTEND_SSH_CONFIG} ~/.ssh/config
    # 开始部署
    - yarn run deploy