Skip to content
Snippets Groups Projects
.gitlab-ci.yml 1.33 KiB
Newer Older
Chris's avatar
Chris committed
stages:
  - test
Chris's avatar
Chris committed
  - build
Chris's avatar
Chris committed
test:
  stage: test
  image: node:15-buster-slim
Chris's avatar
Chris committed
  cache:
Chris's avatar
Chris committed
    paths:
Chris's avatar
Chris committed
  before_script:
    - npm install --global pnpm
    - pnpm config set store-dir .pnpm-store
    - pnpm install
Chris's avatar
Chris committed
  script:
    - pnpx jest src/ --coverage --coverageReporters cobertura
Chris's avatar
Chris committed
  coverage: /All\sfiles.*?\s+(\d+.\d+)/
  artifacts:
    reports:
Chris's avatar
Chris committed
      cobertura: "$CI_PROJECT_DIR/coverage/cobertura-coverage.xml"

build:
  stage: build
  image: node:15-buster-slim
  cache:
    key: "pnpm-store"
    paths:
      - ".pnpm-store"
  before_script:
    - npm install --global pnpm
    - pnpm config set store-dir .pnpm-store
    - pnpm install
  script:
  artifacts:
    paths:
      - dist

# Deploy main branch to contact.greenhost.net
deploy-staging:
  stage: deploy
  # Only run this job for the main branch.
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  image: debian:10
  environment:
    name: staging
    url: https://contact.greenhost.net/staging
  variables:
    FTP_USER: 'webmaster_greenhost_nl'
    FTP_HOST: 'ftp.greenhost.nl'
    DOMAIN_NAME: 'greenhost.net'
    SUBDOMAIN: 'contact'
    SUBFOLDER: '/staging'
    BUILD_FOLDER: './dist'
  before_script:
    - apt-get update
    - apt-get install -y rsync openssh-client
  script:
    - deploy/deploy.sh