This repository has been archived by the owner on Apr 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
69 lines (62 loc) · 1.72 KB
/
.gitlab-ci.yml
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
image: docker:latest
services:
- docker:dind
variables:
DOCKER_DRIVER: overlay2
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
stages:
- build
- package
- deploy
maven-build:
image: maven:3-jdk-8
stage: build
variables:
MAVEN_OPTS: "-Dmaven.repo.local=maven.repository"
cache:
paths:
- maven.repository/
script: "mvn package -B -DskipTests"
artifacts:
paths:
- target/*.jar
docker-build-unstable:
stage: package
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker images
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker push "$CI_REGISTRY_IMAGE:unstable"
- docker logout
only:
- develop
docker-build-master:
stage: package
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker images
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
- docker push "$CI_REGISTRY_IMAGE:latest"
- docker logout
only:
- master
deploy-production:
image: ubuntu:latest
before_script:
- 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'
- eval $(ssh-agent -s)
- echo "$SSH_PROD_PKEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "$SSH_PROD_KNOWN_HOSTS" > ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
stage: deploy
environment:
name: Production
url: $PROD_URL
only:
- master
script:
- ssh -p $SSH_PROD_PORT $SSH_PROD_USER@$SSH_PROD_HOST 'docker-compose -f ~/hoohoot-conf/applications/matrix/docker-compose.yml pull'
- ssh -p $SSH_PROD_PORT $SSH_PROD_USER@$SSH_PROD_HOST 'docker-compose -f ~/hoohoot-conf/applications/matrix/docker-compose.yml up -d'
when: manual