.gitlab-ci.yml 892 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
image: docker:latest

stages:
  - build
  - deploy

build:
  stage: build
  script:
    - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
    - docker image tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:latest"
    - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
    - docker push "$CI_REGISTRY_IMAGE:latest"
  except:
    - master

deploy_production:
  stage: deploy
  script:
    - export http_proxy=http://proxy.esrf.fr:3128
    - 'which ssh-agent || ( apk update && apk add openssh-client )'
    - eval $(ssh-agent -s)
    - echo "$SSH_DEPLOY_KEY_PROD" | ssh-add -
    - mkdir -p ~/.ssh
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
    - ssh -l gitlab-deploy "$DEPLOY_HOST" "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
  environment:
    name: production
    url: http://doi.esrf.fr/
  when: manual
  except:
    - master