-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
50 lines (46 loc) · 1.51 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
stages:
- build
variables:
CLONE_SSH: [email protected]:dgfront/web-spa.git
BRANCH_NAME: $CI_COMMIT_REF_NAME
TAG: $CI_COMMIT_TAG
HARBOR_PROJECT: harbor.deligram.com/flash/flash-app
build:
stage: build
only:
variables:
- $CI_COMMIT_MESSAGE =~ /^\[DEPLOY\]/
- $CI_COMMIT_REF_NAME =~ /master/
image: docker:18.06.2
services:
- docker:18.06.2-dind
before_script:
- apk add --no-cache --update git
- apk add --no-cache --update curl
- 'which ssh-agent || ( apk update && apk add openssh-client )'
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
- mkdir -p ~/.ssh
- chmod 700 ~/.ssh
- echo "StrictHostKeyChecking no " > ~/.ssh/config
- ssh-keyscan git.deligram.com >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
- mkdir -p code
- cd code
- git init
- git remote add origin $CLONE_SSH
- git fetch origin
- git checkout -b $BRANCH_NAME --track origin/$BRANCH_NAME
- echo "$SPA_ENV" > "$(pwd)/.env"
- cat $(pwd)/.env
- ls -la
- export SHORT_SHA="$(git rev-parse --short $CI_COMMIT_SHA)"
- echo "SHORT_SHA=\"$SHORT_SHA\"" >> ../variables
script:
- echo $SHORT_SHA
- docker build .
-f ./devops/Dockerfile
-t ${HARBOR_PROJECT}:$CI_COMMIT_REF_NAME-$SHORT_SHA
- docker login -u ${HARBOR_USER} -p "${HARBOR_PASSWORD}" harbor.deligram.com
- docker push ${HARBOR_PROJECT}:$CI_COMMIT_REF_NAME-$SHORT_SHA
- echo ${HARBOR_PROJECT}:$CI_COMMIT_REF_NAME-$SHORT_SHA