-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path.gitlab-ci.yml
89 lines (82 loc) · 2.33 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
image: docker:stable
stages:
- test
- package
- release
variables:
STAGING_REGISTRY: "registry.gitlab.com"
CONTAINER_TEST_IMAGE: ${STAGING_REGISTRY}/bigdataboutique/${CI_PROJECT_NAME}:commit-${CI_COMMIT_SHA}
services:
- name: docker:dind
command: ["--experimental"]
static-analysis:
stage: test
image: node:14.18.2
cache:
key: ${CI_JOB_NAME}
paths:
- admin-frontend/node_modules
- backend/node_modules
script:
# These are in () to run in a subshell and not modify the real pwd
- (cd admin-frontend && npm install)
- (cd backend && npm install)
- npm run prettier-check
- npm run lint
- npm run test
only:
changes:
- Dockerfile
- backend/**/*
- admin-frontend/**/*
package:
stage: package
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $STAGING_REGISTRY
script:
- docker build --squash -t $CONTAINER_TEST_IMAGE .
- docker push $CONTAINER_TEST_IMAGE
only:
changes:
- Dockerfile
- backend/**/*
- admin-frontend/**/*
release:
stage: release
variables:
GIT_STRATEGY: none
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $STAGING_REGISTRY
script:
- IMAGE_NAME=${STAGING_REGISTRY}/bigdataboutique/${CI_PROJECT_NAME}:`date '+%Y-%m-%d-%H%M'`-${CI_COMMIT_SHA:0:9}
- echo $IMAGE_NAME
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $IMAGE_NAME
- docker push $IMAGE_NAME
- docker tag $CONTAINER_TEST_IMAGE ${STAGING_REGISTRY}/bigdataboutique/${CI_PROJECT_NAME}:latest
- docker push ${STAGING_REGISTRY}/bigdataboutique/${CI_PROJECT_NAME}:latest
only:
refs:
- master
changes:
- Dockerfile
- backend/**/*
- admin-frontend/**/*
dockerhub:
stage: release
variables:
GIT_STRATEGY: none
before_script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $STAGING_REGISTRY
- docker login -u $DOCKERHUB_USER -p "$DOCKERHUB_PASSWORD" docker.io
script:
- IMAGE_NAME=bigdataboutique/elastiquill:${CI_COMMIT_TAG}
- docker pull $CONTAINER_TEST_IMAGE
- docker tag $CONTAINER_TEST_IMAGE $IMAGE_NAME
- docker push $IMAGE_NAME
- docker tag $CONTAINER_TEST_IMAGE bigdataboutique/elastiquill:latest
- docker push bigdataboutique/elastiquill:latest
only:
- /^v.*$/
except:
- branches