-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
41 lines (36 loc) · 1.38 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
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
build-master:
stage: build
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:latest" .
- export TAG=$(docker run --rm "$CI_REGISTRY_IMAGE:latest" cat /manifest.txt | awk NR==2)
- docker push "$CI_REGISTRY_IMAGE:latest"
- docker tag "$CI_REGISTRY_IMAGE:latest" "$CI_REGISTRY_IMAGE:$TAG"
- docker push "$CI_REGISTRY_IMAGE:$TAG"
- docker login -u $DOCKER_USERNAME -p $DOCKER_TOKEN
- docker tag "$CI_REGISTRY_IMAGE:latest" "$DOCKER_USERNAME/$CI_PROJECT_NAME:latest"
- docker push "$DOCKER_USERNAME/$CI_PROJECT_NAME:latest"
- docker tag "$DOCKER_USERNAME/$CI_PROJECT_NAME:latest" "$DOCKER_USERNAME/$CI_PROJECT_NAME:$TAG"
- docker push "$DOCKER_USERNAME/$CI_PROJECT_NAME:$TAG"
only:
- master
build:
stage: build
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- no-push
- master
build-no-push:
stage: build
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- export TAG=$(docker run --rm "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" cat /manifest.txt | awk NR==2)
- docker tag "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" "$CI_REGISTRY_IMAGE:$TAG"
only:
- no-push