.gitlab-ci.yml 1.95 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
  image:
    name: gcr.io/kaniko-project/executor:debug
    entrypoint: [""]
22
  script:
23 24
    - 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
25

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

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

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