.gitlab-ci.yml 1.09 KB
Newer Older
Antoine Roux's avatar
Antoine Roux committed
1 2 3
variables:
  DOCKER_IMAGE_FULLNAME: $CI_REGISTRY/$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG

Axel Bocciarelli's avatar
Axel Bocciarelli committed
4
stages:
Axel Bocciarelli's avatar
Axel Bocciarelli committed
5
  - test
Axel Bocciarelli's avatar
Axel Bocciarelli committed
6 7 8
  - build
  - deploy

Axel Bocciarelli's avatar
Axel Bocciarelli committed
9
Lint:
Axel Bocciarelli's avatar
Axel Bocciarelli committed
10
  stage: test
Axel Bocciarelli's avatar
Axel Bocciarelli committed
11 12 13 14 15
  image: node:12.14.1
  script:
    - npm ci
    - npm run lint

Axel Bocciarelli's avatar
Axel Bocciarelli committed
16 17 18 19 20 21 22
Test:
  stage: test
  image: node:12.14.1
  script:
    - npm ci
    - npm run test

Axel Bocciarelli's avatar
Axel Bocciarelli committed
23 24 25 26 27
.docker-template:
  image: docker:latest
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY

Axel Bocciarelli's avatar
Axel Bocciarelli committed
28 29 30 31 32 33 34 35 36
Build:
  extends: .docker-template
  stage: build
  script:
    - docker build --pull -t "$DOCKER_IMAGE_FULLNAME" .
  only:
    - master

Build and publish:
Axel Bocciarelli's avatar
Axel Bocciarelli committed
37
  extends: .docker-template
Antoine Roux's avatar
Antoine Roux committed
38 39
  stage: build
  script:
Antoine Roux's avatar
Antoine Roux committed
40 41
    - docker build --pull -t "$DOCKER_IMAGE_FULLNAME" .
    - docker push "$DOCKER_IMAGE_FULLNAME"
42 43
  only:
    - tags
Antoine Roux's avatar
Antoine Roux committed
44

Axel Bocciarelli's avatar
Axel Bocciarelli committed
45
Deploy:
Axel Bocciarelli's avatar
Axel Bocciarelli committed
46
  extends: .docker-template
Antoine Roux's avatar
Antoine Roux committed
47 48 49 50
  stage: deploy
  variables:
    GIT_STRATEGY: none
  image: docker-registry.esrf.fr/cs/ci-deploy
Antoine Roux's avatar
Antoine Roux committed
51
  script:
Antoine Roux's avatar
Antoine Roux committed
52 53
    - deploy "$DOCKER_IMAGE_FULLNAME" "production"
    - retag "$DOCKER_IMAGE_FULLNAME" "production"
Antoine Roux's avatar
Antoine Roux committed
54 55 56 57
  environment:
    name: production
    url: https://datahub.esrf.fr/
  when: manual
58
  only:
59
    - tags