-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
86 lines (81 loc) · 1.97 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
stages:
- test
- build
- deploy
test-backend:
tags: ["docker"]
image: amazoncorretto:21-alpine
stage: test
rules:
- if: $CI_COMMIT_REF_PROTECTED == "true"
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
before_script:
- mv /cache/$CI_PROJECT_NAME/.gradle ~/ || echo ""
script:
- cd backend
- ./gradlew test
after_script:
- mv ~/.gradle /cache/$CI_PROJECT_NAME/
build-backend:
tags: ["docker"]
image: amazoncorretto:21-alpine
stage: build
rules:
- if: $CI_COMMIT_REF_PROTECTED == "true"
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
before_script:
- mv /cache/$CI_PROJECT_NAME/.gradle ~/ || echo ""
script:
- cd backend
- ./gradlew build
after_script:
- mv ~/.gradle /cache/$CI_PROJECT_NAME/
artifacts:
when: on_success
paths:
- backend/build/libs/backend-all.jar
build-frontend:
tags: ["docker"]
image: node:alpine
stage: build
rules:
- if: $CI_COMMIT_REF_PROTECTED == "true"
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
script:
- cd frontend
- export VITE_API_BASE_URL=$API_BASE_URL
- export VITE_HTML_BASE_URL=/sushi-counter/
- npm install
- npm run build
artifacts:
when: on_success
paths:
- frontend/dist/
deploy-backend:
tags: ["docker"]
stage: deploy
image: docker
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- echo "Deploying backend..."
- mv backend/build/libs/backend-all.jar $COMMON_SERVICES/sushi-counter/_backend.jar
- cd $COMMON_SERVICES/sushi-counter
- docker compose down
- rm -f backend.jar
- mv _backend.jar backend.jar
- docker compose up -d
deploy-frontend:
tags: ["docker"]
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- echo "Deploying frontend..."
- mv ./frontend/dist/ $COMMON_WWW
- cd $COMMON_WWW
- rm -rf sushi-counter/
- mv dist sushi-counter