-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
67 lines (62 loc) · 1.6 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
image: docker:stable
stages:
- test
- release
variables:
STAGING_REGISTRY: "registry.gitlab.com"
TEST_IMAGE_NAME: ${STAGING_REGISTRY}/bigdataboutique/${CI_PROJECT_NAME}:commit-${CI_COMMIT_SHA}
test:
image: python:3.9
stage: test
before_script:
- pip install -r requirements.txt
script:
- python -m unittest discover test
only:
changes:
- bogi/**/*
- test/**/*
- requirements.txt
except:
- /^v.*$/
release:
stage: release
services:
- docker:dind
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $STAGING_REGISTRY
script:
- IMAGE_NAME=${STAGING_REGISTRY}/bigdataboutique/${CI_PROJECT_NAME}:`date '+%Y-%m-%d-%H%M'`-${CI_COMMIT_SHA:0:9}
- docker build -t $TEST_IMAGE_NAME .
- docker push $TEST_IMAGE_NAME
- docker tag $TEST_IMAGE_NAME $IMAGE_NAME
- docker push $IMAGE_NAME
only:
changes:
- bogi/**/*
- test/**/*
- requirements.txt
refs:
- master
- /^v.*$/
dockerhub:
stage: release
services:
- name: docker:dind
command: ["--experimental"]
variables:
GIT_STRATEGY: none
before_script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $STAGING_REGISTRY
- docker login -u $DOCKERHUB_USER -p "$DOCKERHUB_PASSWORD" docker.io
script:
- IMAGE_NAME=bigdataboutique/bogi:${CI_COMMIT_TAG}
- docker pull $TEST_IMAGE_NAME
- docker tag $TEST_IMAGE_NAME $IMAGE_NAME
- docker push $IMAGE_NAME
- docker tag $TEST_IMAGE_NAME bigdataboutique/bogi:latest
- docker push bigdataboutique/bogi:latest
only:
- /^v.*$/
except:
- branches