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

4
default:
5
6
7
8
  retry: 2
  interruptible: true

stages:
9
  - lint
10
  - build
11
  - test
12
13
14
  - deploy

lint:
15
  stage: lint
16
  tags: [docker]
17
  image: node:12-buster
Guillaume Perréal's avatar
Guillaume Perréal committed
18
19
  variables:
    NPM_CONFIG_CACHE: "$CI_PROJECT_DIR/.npm"
20
21
22
23
24
25
  before_script:
    - node --version
    - npm --version
    - npm install
  script:
    - npm run lint
Guillaume Perréal's avatar
Guillaume Perréal committed
26
  cache:
27
    key: "$CI_COMMIT_REF_SLUG-$CI_JOB_NAME"
Guillaume Perréal's avatar
Guillaume Perréal committed
28
29
    paths:
      - "$NPM_CONFIG_CACHE"
30

31
32
33
34
docker:
  stage: build
  tags: [dind]
  variables:
35
    IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
36
37
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
38
39
40
41
42
  script:
    - docker build --tag "$IMAGE" .
    - docker run --rm "$IMAGE" build
    - docker push "$IMAGE"

43
44
45
46
npm-test:
  stage: test
  image: node:12
  before_script:
47
48
49
50
    - apt-get update -yq && apt-get install -yq pandoc wkhtmltopdf
    - mkdir -p $HOME/prezbuilder
    - cd $HOME/prezbuilder
    - npm install "git+${CI_REPOSITORY_URL}#${CI_COMMIT_REF_NAME}"
51
    - ln -s $HOME/prezbuilder/node_modules/.bin/prezbuilder /usr/local/bin/prezbuilder
52
    - cd $CI_PROJECT_DIR
53
54
  script:
    - prezbuilder build src public
55
    - "[ -e public/index.html ]"
56
57
58
59
60
61
62
63
64

docker-test:
  stage: test
  tags: [dind]
  before_script:
    - wget "${CI_PROJECT_URL}/-/raw/${CI_COMMIT_REF_NAME}/bin/prezbuilder-docker?inline=false" -O /usr/local/bin/prezbuilder-docker
    - chmod a+rx /usr/local/bin/prezbuilder-docker
  script:
    - prezbuilder-docker build src public
65
    - "[ -e public/index.html ]"
66

67
pages:
68
69
70
  extends: .prezbuilder
  variables:
    PREZBUILDER_IMAGE: "$CI_REGISTRY_IMAGE"
71
    PREZBUILDER_TAG: "$CI_COMMIT_REF_NAME"
Guillaume Perréal's avatar
Guillaume Perréal committed
72
  rules:
73
    - if: $CI_COMMIT_TAG