stages: - build - deploy variables: NODE_VERSION: "18" cache: key: ${CI_COMMIT_REF_SLUG} paths: - node_modules/ before_script: - npm config set registry https://registry.npmmirror.com build-dev: stage: build only: - develop tags: - docker image: node:18-alpine script: - npm ci - npm run type-check || true - npm run lint || true - npm run build artifacts: name: "dev-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA" paths: - dist/ expire_in: 1 day deploy-dev: stage: deploy only: - develop tags: - docker image: alpine:latest before_script: - apk add --no-cache openssh-client rsync script: - eval $(ssh-agent -s) - mkdir -p ~/.ssh && chmod 700 ~/.ssh - ssh-keyscan -H $DEV_SERVER_IP >> ~/.ssh/known_hosts 2>/dev/null - echo "$DEV_SSH_PASSWORD" | sshpass ssh -o StrictHostKeyChecking=no root@$DEV_SERVER_IP "mkdir -p $DEV_SERVER_PATH && chmod 755 $DEV_SERVER_PATH" - sshpass -p "$DEV_SSH_PASSWORD" rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no" dist/ root@$DEV_SERVER_IP:$DEV_SERVER_PATH needs: - job: build-dev artifacts: true when: manual build-prod: stage: build only: - master - main tags: - docker image: node:18-alpine script: - npm ci - npm run type-check || true - npm run lint || true - npm run build artifacts: name: "prod-$CI_COMMIT_REF_NAME-$CI_COMMIT_SHA" paths: - dist/ expire_in: 7 days deploy-prod: stage: deploy only: - master - main tags: - docker image: alpine:latest before_script: - apk add --no-cache openssh-client rsync sshpass script: - eval $(ssh-agent -s) - mkdir -p ~/.ssh && chmod 700 ~/.ssh - ssh-keyscan -H $PROD_SERVER_IP >> ~/.ssh/known_hosts 2>/dev/null - echo "$PROD_SSH_PASSWORD" | sshpass ssh -o StrictHostKeyChecking=no root@$PROD_SERVER_IP "mkdir -p $PROD_SERVER_PATH && chmod 755 $PROD_SERVER_PATH" - sshpass -p "$PROD_SSH_PASSWORD" rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no" dist/ root@$PROD_SERVER_IP:$PROD_SERVER_PATH needs: - job: build-prod artifacts: true when: manual