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

4
default:
5 6
  image: node:12-buster
  tags: [docker]
7 8 9 10
  retry: 2
  interruptible: true

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

15 16
node_modules:
  stage: build
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 48 49 50 51 52 53 54 55
  needs:
    - node_modules
  script:
    - npm run lint

run-from-sources:
  stage: test
  needs:
    - node_modules
56
  script:
57
    - bin/prezbuilder build src public
58
    - "[ -e public/index.html ]"
59

60
run-from-npm:
61
  stage: test
62 63
  variables:
    GIT_STRATEGY: none
64
  before_script:
65 66 67 68 69
    - 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}"
70
  script:
71 72
    - node_modules/.bin/prezbuilder build $CI_PROJECT_DIR/src $CI_PROJECT_DIR/public
    - "[ -e $CI_PROJECT_DIR/public/index.html ]"
73

74
pages:
75 76 77
  extends: .prezbuilder
  variables:
    PREZBUILDER_IMAGE: "$CI_REGISTRY_IMAGE"
78
    PREZBUILDER_TAG: "$CI_COMMIT_REF_NAME"
Guillaume Perréal's avatar
Guillaume Perréal committed
79
  rules:
80
    - if: $CI_COMMIT_TAG