.gitlab-ci.yml 2.25 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
  image: docker:19.03.1
20
  services:
21
    - docker:19.03.1-dind
22 23 24
  variables:
    DOCKER_HOST: tcp://docker:2375
    DOCKER_DRIVER: overlay2
25 26 27 28 29
    # Create the certificates inside this directory for both the server
    # and client. The certificates used by the client will be created in
    # /certs/client so we only need to share this directory with the
    # volume mount in `config.toml`.
    DOCKER_TLS_CERTDIR: "/certs"
30
  before_script:
31
    - docker info
32 33
    - docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
  script:
34 35
    - docker build -t $CI_REGISTRY_IMAGE:latest -f Dockerfile.ci .
    - docker push $CI_REGISTRY_IMAGE:latest
36 37
  tags:
    - docker-privileged
Christophe Benz's avatar
fixup!  
Christophe Benz committed
38

39
Generate files:
40
  stage: generate
41
  image: $CI_REGISTRY_IMAGE:latest
42 43
  variables:
    CATALOG_URL: https://git.opendatafrance.net/scdl/catalog/raw/master/catalog.json
44
    CONTRIBUTING_MD_URL: https://git.opendatafrance.net/scdl/catalog/raw/master/CONTRIBUTING.md
45 46 47
  before_script:
    - pip3 install --requirement requirements.txt
  script:
48
    - ./scripts/generate_files.sh
49 50 51
  artifacts:
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
    paths:
Christophe Benz's avatar
fixup!  
Christophe Benz committed
52 53 54 55
      - docs/CONTRIBUTING.md
      - docs/SUMMARY.md
      - docs/schemas/
      - docs/templates/
56 57

Build Gitbook:
Christophe Benz's avatar
Christophe Benz committed
58
  stage: build
59
  image: $CI_REGISTRY_IMAGE:latest
60
  script:
61
    - ./scripts/build_gitbook.sh
62
  artifacts:
63
    name: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
64 65
    paths:
      - _book/
Christophe Benz's avatar
fixup!  
Christophe Benz committed
66
      - "$PDF_FILE"
67

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