.gitlab-ci.yml 1.26 KB
Newer Older
1 2 3
include:
  - local: 'prezbuilder-ci.yml'

4
default:
5
  tags: [docker]
6 7 8 9
  retry: 2
  interruptible: true

stages:
10
  - build
11
  - test
12 13
  - deploy

14 15
node_modules:
  stage: build
16
  image: node:12-buster
Guillaume Perréal's avatar
Guillaume Perréal committed
17 18
  variables:
    NPM_CONFIG_CACHE: "$CI_PROJECT_DIR/.npm"
19
  script:
20
    - npm install
Guillaume Perréal's avatar
Guillaume Perréal committed
21
  cache:
22
    key: "$CI_COMMIT_REF_SLUG-$CI_JOB_NAME"
Guillaume Perréal's avatar
Guillaume Perréal committed
23 24
    paths:
      - "$NPM_CONFIG_CACHE"
25 26 27 28
  artifacts:
    expire_in: 1 day
    paths:
      - node_modules/
29

30
docker-image:
31 32 33
  stage: build
  tags: [dind]
  variables:
34 35 36 37
    PUBLIC_IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
    PREZBUILDER_IMAGE: prezbuilder
    PREZBUILDER_TAG: "$CI_COMMIT_SHA"
    LOCAL_IMAGE: "$PREZBUILDER_IMAGE:$PREZBUILDER_TAG"
38
  script:
39 40 41 42 43
    - set -x
    - docker pull "$PUBLIC_IMAGE" || exit 0
    - docker build --cache-from "node:buster-12,$PUBLIC_IMAGE" --tag "$LOCAL_IMAGE" --tag "$PUBLIC_IMAGE" .
    - docker run --rm "$LOCAL_IMAGE" build
    - bash -x bin/prezbuilder-docker build src public
44
    - "[ -e public/index.html ]"
45
    - docker push "$PUBLIC_IMAGE"
46

47
lint:
48
  stage: test
49
  image: node:12-buster
50 51 52 53 54
  needs:
    - node_modules
  script:
    - npm run lint

55
pages:
56 57 58
  extends: .prezbuilder
  variables:
    PREZBUILDER_IMAGE: "$CI_REGISTRY_IMAGE"
59
    PREZBUILDER_TAG: "$CI_COMMIT_REF_NAME"
Guillaume Perréal's avatar
Guillaume Perréal committed
60
  rules:
61
    - if: $CI_COMMIT_TAG