-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
138 lines (130 loc) · 3.31 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
stages:
- prepare
- qa
- docker
- deploy
npm:
stage: prepare
image: node:10.16-slim
script:
- npm ci
artifacts:
paths:
- node_modules/
expire_in: 30 days
when: on_success
npm-audit:
stage: qa
image: node:10.16-slim
script:
- npm run audit-ci
allow_failure: true
dependencies:
- npm
.test:
stage: qa
image: node:10.16-slim
script:
- npm run coverage
dependencies:
- npm
artifacts:
paths:
- coverage/
expire_in: 30 days
when: on_success
jest:
extends: .test
except:
- master
jest-master:
extends: .test
after_script:
- npm install --only=prod codecov
- ./node_modules/.bin/codecov --token="${CODECOV_TOKEN}"
only:
- master
docker:develop:
stage: docker
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
variables:
DOCKER_USERNAME: morawskim
script:
- DOCKER_AUTH=$(echo -n $DOCKER_USERNAME:$DOCKER_PASSWORD | base64)
- |
cat > /kaniko/.docker/config.json << EOF
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "$DOCKER_AUTH"
},
"$CI_REGISTRY": {
"username": "$CI_REGISTRY_USER",
"password": "$CI_REGISTRY_PASSWORD"
}
}
}
EOF
- >
/kaniko/executor --context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $CI_REGISTRY_IMAGE
--destination $DOCKER_USERNAME/packtpub-free-learning
only:
- develop
docker:master:
stage: docker
image:
name: gcr.io/kaniko-project/executor:debug
entrypoint: [""]
variables:
DOCKER_USERNAME: morawskim
script:
- DOCKER_AUTH=$(echo -n $DOCKER_USERNAME:$DOCKER_PASSWORD | base64)
- |
cat > /kaniko/.docker/config.json << EOF
{
"auths": {
"https://index.docker.io/v1/": {
"auth": "$DOCKER_AUTH"
},
"$CI_REGISTRY": {
"username": "$CI_REGISTRY_USER",
"password": "$CI_REGISTRY_PASSWORD"
}
}
}
EOF
- TAG=$(echo $CI_COMMIT_TAG | sed 's/[^0-9\.]*//g')
- echo $TAG
- >
/kaniko/executor --context $CI_PROJECT_DIR
--dockerfile $CI_PROJECT_DIR/Dockerfile
--destination $CI_REGISTRY_IMAGE:$TAG
--destination $CI_REGISTRY_IMAGE:stable
--destination $DOCKER_USERNAME/packtpub-free-learning:$TAG
--destination $DOCKER_USERNAME/packtpub-free-learning:stable
only:
- tags
deploy:production:
stage: deploy
image: docker:19.03-dind
environment:
name: production
# only:
# - master
when: manual
before_script:
- 'which ssh-agent || ( apk update && apk add openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
script:
- TMP_PATH=$(mktemp -d)
- echo "$PROD_CONFIG" > deploy/.env-sensi
- DOCKER_AUTH=$(echo -n $CI_DEPLOY_USER:$CI_DEPLOY_PASSWORD | base64)
- echo "{\"auths\":{\"$CI_REGISTRY\":{\"auth\":\"$DOCKER_AUTH\"}}}" > $TMP_PATH/config.json
- DOCKER_HOST=ssh://deployer@35.210.15.98 docker --config $TMP_PATH stack deploy --compose-file deploy/docker-compose.sensi.yml --with-registry-auth packtpub-free-learning