.gitlab-ci.yml 1.25 KB
Newer Older
Lukas Burgey's avatar
Add CI  
Lukas Burgey committed
1
2
3
4
5
image: golang:1.12-alpine

stages:
  - lint
  - build
Lukas Burgey's avatar
Lukas Burgey committed
6
  - deploy
Lukas Burgey's avatar
Add CI  
Lukas Burgey committed
7
8

before_script:
Lukas Burgey's avatar
Lukas Burgey committed
9
  - apk add --no-cache git make rsync openssh-client
Lukas Burgey's avatar
Add CI  
Lukas Burgey committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  - mkdir -p /go/src/git.scc.kit.edu/feudal /go/src/_/builds
  - cp -r $CI_PROJECT_DIR /go/src/git.scc.kit.edu/feudal/feudalClient
  - ln -s /go/src/git.scc.kit.edu/feudal /go/src/_/builds/feudalClient
  - make dep

lint:
  stage: lint
  script:
    make lint

build:
  stage: build
  script:
    - make build
  artifacts:
    paths:
      - feudalClient
Lukas Burgey's avatar
Lukas Burgey committed
27

Lukas Burgey's avatar
Lukas Burgey committed
28
deploy-dev:
Lukas Burgey's avatar
Lukas Burgey committed
29
30
31
  stage: deploy
  only:
    - dev
Lukas Burgey's avatar
Lukas Burgey committed
32
33
34
35
  environment:
    name: dev
  dependencies:
    - build
Lukas Burgey's avatar
Lukas Burgey committed
36
37
38
39
40
41
42
  script:
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - rsync -v feudalClient $DEV_USER@$DEV_HOST:bin/feudalClientDev
Lukas Burgey's avatar
Lukas Burgey committed
43
    - ssh $DEV_USER@$DEV_HOST -- systemctl --user restart devClient@0 devClient@1 devClient@2
Lukas Burgey's avatar
Lukas Burgey committed
44

Lukas Burgey's avatar
Lukas Burgey committed
45
deploy-master:
Lukas Burgey's avatar
Lukas Burgey committed
46
47
48
  stage: deploy
  only:
    - master
Lukas Burgey's avatar
Lukas Burgey committed
49
50
51
52
  environment:
    name: master
  dependencies:
    - build
Lukas Burgey's avatar
Lukas Burgey committed
53
54
55
56
57
58
59
  script:
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - rsync -v feudalClient $DEV_USER@$DEV_HOST:bin/feudalClient