.gitlab-ci.yml 1.82 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
    IMAGE: "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME"
35
36
  before_script:
    - docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" "$CI_REGISTRY"
37
38
  script:
    - docker build --tag "$IMAGE" .
39
40
41
42
    - docker run --rm "$IMAGE" build src public
    - "[ -e public/index.html ]"
    - rm -rf public/*
    - bin/prezbuilder-docker build src public
43
44
    - docker push "$IMAGE"

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

run-from-sources:
  stage: test
55
  image: node:12-buster
56
57
  needs:
    - node_modules
58
59
  before_script:
    - apt-get update -yq && apt-get install -yq pandoc wkhtmltopdf
60
  script:
61
    - bin/prezbuilder build src public
62
    - "[ -e public/index.html ]"
63

64
run-from-npm:
65
  stage: test
66
  image: node:12-buster
67
  needs: []
68
69
  variables:
    GIT_STRATEGY: none
70
  before_script:
71
72
73
74
75
    - apt-get update -yq && apt-get install -yq pandoc wkhtmltopdf
    - set -x
    - mkdir -p $HOME/prezbuilder
    - cd $HOME/prezbuilder
    - npm install "git+${CI_REPOSITORY_URL}#${CI_COMMIT_REF_NAME}"
76
  script:
77
78
    - node_modules/.bin/prezbuilder build $CI_PROJECT_DIR/src $CI_PROJECT_DIR/public
    - "[ -e $CI_PROJECT_DIR/public/index.html ]"
79

80
pages:
81
82
83
  extends: .prezbuilder
  variables:
    PREZBUILDER_IMAGE: "$CI_REGISTRY_IMAGE"
84
    PREZBUILDER_TAG: "$CI_COMMIT_REF_NAME"
Guillaume Perréal's avatar
Guillaume Perréal committed
85
  rules:
86
    - if: $CI_COMMIT_TAG