-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
90 lines (81 loc) · 2.54 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
87
88
89
90
# Define the Docker image used for the jobs
image: maven:latest
# Define the stages used in the pipeline
stages:
- build
- test
- deploy
# Define variables
variables:
MAVEN_CLI_OPTS: "-s .m2/settings.xml --batch-mode"
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository"
# Cache dependencies to speed up builds
cache:
paths:
- .m2/repository/
- node_modules/
# This job builds the Spring Boot application
build_spring_boot:
stage: build
script:
- cd cardgamehub
- mvn $MAVEN_CLI_OPTS verify
artifacts:
name: "Maven artifacts from $CI_PROJECT_NAME on $CI_COMMIT_REF_SLUG"
paths:
- "**/target"
reports:
# Declare the JUnit reports for GitLab to pick them up
junit:
- "cardgamehub/src/test/**/*Tests.java"
only:
variables:
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# This job runs tests for the Spring Boot application
test_spring_boot:
stage: test
script:
- cd cardgamehub
- mvn $MAVEN_CLI_OPTS test
only:
variables:
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# This job installs node dependencies and builds the React app
build_react:
stage: build
image: node:latest # Specify a Node.js Docker image
script:
- cd cardgamehubfrontend
- npm install
- npm run build # It's more common to use `npm run build` for React apps in CI/CD pipelines
artifacts:
paths:
- cardgamehubfrontend/build
only:
variables:
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# This job runs tests for the React application
test_react:
stage: test
image: node:latest
script:
- cd cardgamehubfrontend
- npm install
# - npm test # We don't have tests for the React app yet
only:
variables:
- $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# This job handles the deployment of both applications
deploy_to_staging:
stage: deploy
image: registry.gitlab.com/gitlab-org/release-cli:latest
rules:
- if: $CI_COMMIT_TAG
when: never # Do not run this job when a tag is created manually
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH # Run this job when commits are pushed or merged to the default branch
script:
- echo "running release_job for $TAG"
release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
tag_name: 'v0.$CI_PIPELINE_IID' # The version is incremented per pipeline.
description: 'v0.$CI_PIPELINE_IID'
ref: '$CI_COMMIT_SHA' # The tag is created from the pipeline SHA.