.gitlab-ci.yml 1.8 KB
Newer Older
lukas.burgey's avatar
lukas.burgey committed
1 2
image: golang:1.13-alpine

Lukas Burgey's avatar
Add CI  
Lukas Burgey committed
3 4 5
stages:
  - lint
  - build
Lukas Burgey's avatar
Lukas Burgey committed
6
  - deploy
Lukas Burgey's avatar
Add CI  
Lukas Burgey committed
7 8 9 10

lint:
  stage: lint
  script:
Lukas Burgey's avatar
Lukas Burgey committed
11 12
    - apk add --no-cache git make
    - make lint
Lukas Burgey's avatar
Add CI  
Lukas Burgey committed
13 14 15 16

build:
  stage: build
  script:
Lukas Burgey's avatar
Lukas Burgey committed
17
    - apk add --no-cache git make
Lukas Burgey's avatar
Lukas Burgey committed
18
    - make build-static
lukas.burgey's avatar
lukas.burgey committed
19
    - ./feudalClient --version
Lukas Burgey's avatar
Add CI  
Lukas Burgey committed
20 21 22
  artifacts:
    paths:
      - feudalClient
Lukas Burgey's avatar
Lukas Burgey committed
23

24

lukas.burgey's avatar
lukas.burgey committed
25
# this needs a volume mounted to the docker runner like so:
26
# volumes = ["/path/to/binaries:/deployDestination:rw"]
Lukas Burgey's avatar
Lukas Burgey committed
27
deploy-dev:
Lukas Burgey's avatar
Lukas Burgey committed
28 29 30
  stage: deploy
  only:
    - dev
Lukas Burgey's avatar
Lukas Burgey committed
31 32 33 34
  environment:
    name: dev
  dependencies:
    - build
35 36 37 38 39 40 41
  before_script:
    - apk add openssh
    - mkdir -p ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 600 -R ~/.ssh
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
lukas.burgey's avatar
lukas.burgey committed
42 43 44 45
  script:
    - mkdir -p /deployDestination/dev
    - cp feudalClient /deployDestination/dev
    - date -Iseconds > /deployDestination/dev/lastCIDeploy
46 47
    # -tt to force pseudo-terminal allocation (as sudo requires a tty)
    - ssh -tt ${DEPLOYMENT_USER}@${DEPLOYMENT_HOST} sudo systemctl restart ${DEPLOYMENT_SERVICE_DEV}
lukas.burgey's avatar
lukas.burgey committed
48 49 50 51 52 53 54 55 56 57 58

# this needs a volume mounted to the docker runner like so:
# volumes = ["/path/to/binaries:/deployDestination:rw"]
deploy-master:
  stage: deploy
  only:
    - master
  environment:
    name: master
  dependencies:
    - build
59 60 61 62 63 64 65
  before_script:
    - apk add openssh
    - mkdir -p ~/.ssh
    - echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
    - chmod 600 -R ~/.ssh
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
Lukas Burgey's avatar
Lukas Burgey committed
66
  script:
lukas.burgey's avatar
lukas.burgey committed
67
    - mkdir -p /deployDestination
68 69
    - cp feudalClient /deployDestination
    - date -Iseconds > /deployDestination/lastCIDeploy
70 71
    # -tt to force pseudo-terminal allocation (as sudo requires a tty)
    - ssh -tt ${DEPLOYMENT_USER}@${DEPLOYMENT_HOST} sudo systemctl restart ${DEPLOYMENT_SERVICE_MASTER}