.gitlab-ci.yml 2.11 KB
Newer Older
1
stages:
2
  - docker
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: docker
14 15 16 17 18
  only:
    changes:
      - Dockerfile.ci
    refs:
      - master
19 20 21 22
    variables:
      # Do not build Docker image from scheduled jobs.
      # Cf https://gitlab.com/gitlab-org/gitlab/issues/27318#note_215688359
      - $CI_PIPELINE_SOURCE == "push"
23 24 25
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
26
  script:
27 28
    - echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"}}}" > /kaniko/.docker/config.json
    - /kaniko/executor --context $CI_PROJECT_DIR --dockerfile $CI_PROJECT_DIR/Dockerfile.ci --destination $CI_REGISTRY_IMAGE:$CI_COMMIT_TAG
Christophe Benz's avatar
fixup!  
Christophe Benz committed
29

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

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

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