-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
91 lines (71 loc) · 2.44 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
91 lines (71 loc) · 2.44 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
stages:
- sonarqube-check-frontend
- sonarqube-check
- publish
- deploy
variables:
TAG_LATEST: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:latest
TAG_COMMIT: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_NAME:$CI_COMMIT_SHORT_SHA
STAGE_IMAGE_APP_TAG: spithub.ch/development/amazing_app/app:stage
PROD_IMAGE_APP_TAG: spithub.ch/development/amazing_app/app:prod
sonarqube-check-frontend:
image:
name: sonarsource/sonar-scanner-cli:latest
entrypoint: [""]
stage: sonarqube-check-frontend
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- sonar-scanner
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == 'main'
sonarqube-check:
image: maven:3.9.0-eclipse-temurin-19
stage: sonarqube-check
variables:
SONAR_USER_HOME: "${CI_PROJECT_DIR}/.sonar" # Defines the location of the analysis task cache
GIT_DEPTH: "0" # Tells git to fetch all the branches of the project, required by the analysis task
cache:
key: "${CI_JOB_NAME}"
paths:
- .sonar/cache
script:
- cd spithub-api
- mvn verify sonar:sonar -Dsonar.projectKey=b-ls-mi-sip_projects-2023_mip2023-01-als_AYdM7i8kkiF_JV0oBbnw -Dsonar.projectName='mip2023-01-als'
allow_failure: true
rules:
- if: $CI_COMMIT_BRANCH == 'main'
publish:
image: tmaier/docker-compose:latest
stage: publish
services:
- docker:dind
script:
- docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY
- docker compose build --progress=plain
- docker compose push
rules:
- if: $CI_COMMIT_BRANCH == 'main'
deploy:
image: alpine:latest
stage: deploy
tags:
- deployment
script:
- chmod og= $ID_RSA
- apk update && apk add openssh-client
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker login -u $CI_REGISTRY_USER -p $CI_JOB_TOKEN $CI_REGISTRY"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker compose down --remove-orphans"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker compose pull"
- ssh -i $ID_RSA -o StrictHostKeyChecking=no $SERVER_USER@$SERVER_IP "docker compose up -d"
environment:
name: production
url: 147.86.10.134
rules:
- if: $CI_COMMIT_BRANCH == 'main'