Skip to content
Snippets Groups Projects
This GitLab CI configuration is valid. Learn more
.gitlab-ci.yml 3.09 KiB
image: "registry.gitlab.clubelek.fr/cdf2020/libraries/communication/messages/protobuf-compiler:latest"

variables:
  PYTHON_GIT_URL: ssh://git@gitlab.clubelek.fr:2222/cdf2020/libraries/communication/messages/messages-schemas-python.git
  CPP_GIT_URL: ssh://git@gitlab.clubelek.fr:2222/cdf2020/libraries/communication/messages/messages-schemas-cpp.git
  NANOPB_GIT_URL: ssh://git@gitlab.clubelek.fr:2222/cdf2020/libraries/communication/messages/messages-schemas-nanopb.git
  EAMS_GIT_URL: ssh://git@gitlab.clubelek.fr:2222/cdf2020/libraries/communication/messages/messages-schemas-eams.git

before_script:
  - export COMMIT_MSG="ci/Compilation of messages-schemas/$CI_COMMIT_SHA"
  - "which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )"
  - eval $(ssh-agent -s)
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh
  - ssh-keyscan -p 2222 -t rsa gitlab.clubelek.fr >> ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts
  - git config --global user.email "noreply@clubelek.fr"
  - git config --global user.name "Compiler bot"

build:
  stage: build
  script:
    - make
    - ls python/ cpp/ nanopb/ eams/
  artifacts:
    paths:
      - python/
      - cpp/
      - nanopb/
      - eams/
    expire_in: 30min
  only:
    changes:
      - messages/*
    refs:
      - master

deploy_python:
  stage: deploy
  dependencies:
    - build
  script:
    - echo "$SSH_PRIVATE_KEY_PYTHON" | tr -d '\r' | ssh-add -
    - git clone $PYTHON_GIT_URL
    - rm -rf messages-schemas-python/*
    - mv python/* messages-schemas-python/
    - cd messages-schemas-python
    - git add .
    - git commit -m "$COMMIT_MSG" || echo "Nothing to commit."
    - git push -u $PYTHON_GIT_URL master
  only:
    changes:
      - messages/*
    refs:
      - master

deploy_cpp:
  stage: deploy
  dependencies:
    - build
  script:
    - echo "$SSH_PRIVATE_KEY_CPP" | tr -d '\r' | ssh-add -
    - git clone $CPP_GIT_URL
    - rm -rf messages-schemas-cpp/*
    - mv cpp/* messages-schemas-cpp/
    - cd messages-schemas-cpp
    - git add .
    - git commit -m "$COMMIT_MSG" || echo "Nothing to commit."
    - git push -u $CPP_GIT_URL master
  only: