.gitlab-ci.yml 1.92 KB
Newer Older
1 2
stages:
  - build_docker_image
3
  - generate
4 5
  - build
  - deploy
Christophe Benz's avatar
Christophe Benz committed
6

Christophe Benz's avatar
fixup!  
Christophe Benz committed
7
variables:
8
  LC_ALL: fr_FR.UTF-8
Christophe Benz's avatar
fixup!  
Christophe Benz committed
9
  PDF_FILE: Socle Commun des Données Locales.pdf
10
  TZ: Europe/Paris
11

12
Build Docker image:
13
  stage: build_docker_image
14 15 16 17 18
  only:
    changes:
      - Dockerfile.ci
    refs:
      - master
19 20 21 22 23 24 25 26 27
  image: docker:stable
  services:
    - docker:dind
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_DRIVER: overlay2
  before_script:
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  script:
28 29
    - docker build -t $CI_REGISTRY_IMAGE:latest -f Dockerfile.ci .
    - docker push $CI_REGISTRY_IMAGE:latest
30 31
  tags:
    - docker-privileged
Christophe Benz's avatar
fixup!  
Christophe Benz committed
32

33
Generate files:
34
  stage: generate
35
  image: $CI_REGISTRY_IMAGE:latest
36 37
  variables:
    CATALOG_URL: https://git.opendatafrance.net/scdl/catalog/raw/master/catalog.json
38
    CONTRIBUTING_MD_URL: https://git.opendatafrance.net/scdl/catalog/raw/master/CONTRIBUTING.md
39 40 41
  before_script:
    - pip3 install --requirement requirements.txt
  script:
42
    - ./scripts/generate_files.sh
43 44 45
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
    paths:
46
      - CONTRIBUTING.md
47 48 49 50 51
      - SUMMARY.md
      - schemas/
      - templates/

Build Gitbook:
Christophe Benz's avatar
Christophe Benz committed
52
  stage: build
53
  image: $CI_REGISTRY_IMAGE:latest
54
  script:
55
    - ./scripts/build_gitbook.sh
56
  artifacts:
57
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
58 59
    paths:
      - _book/
Christophe Benz's avatar
fixup!  
Christophe Benz committed
60
      - "$PDF_FILE"
61

Christophe Benz's avatar
Christophe Benz committed
62
Deploy Gitbook:
63 64
  stage: deploy
  only:
Christophe Benz's avatar
Christophe Benz committed
65
    - master
66
  image: $CI_REGISTRY_IMAGE:latest
67
  variables:
Christophe Benz's avatar
Christophe Benz committed
68
    SERVER_DIRECTORY: scdl-documentation-static
Christophe Benz's avatar
Christophe Benz committed
69
    SERVER_HOST: scdl.opendatafrance.net
70
    SERVER_USER: validata
71 72
  before_script:
    - eval $(ssh-agent -s)
73
    - ssh-add <(echo "$SSH_PRIVATE_KEY")
74
    - mkdir -p ~/.ssh
75
    - ssh-keyscan -t rsa $SERVER_HOST >> ~/.ssh/known_hosts
Christophe Benz's avatar
Christophe Benz committed
76
  script:
77 78
    - rsync -avz --delete _book/ "$PDF_FILE" ${SERVER_USER}@${SERVER_HOST}:${SERVER_DIRECTORY}/
  environment:
Christophe Benz's avatar
Christophe Benz committed
79 80
    name: Documentation SCDL
    url: https://scdl.opendatafrance.net/docs/