-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
52 lines (45 loc) · 1.21 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
image: docker:latest
services:
- docker:dind
stages:
- build
- notifications
variables:
REGISTRY: "docker.io"
REGISTRY_USER: "robpco"
RELEASE_IMAGE: "${CI_PROJECT_NAME}"
REGISTRY_IMAGE: "${REGISTRY}/${REGISTRY_USER}/${CI_PROJECT_NAME}"
before_script:
- docker login -u "$REGISTRY_USER" -p "$REGISTRY_PASSWORD"
build:
stage: build
script:
- docker build --pull --tag "${REGISTRY_IMAGE}:${CI_COMMIT_TAG}" --tag "${REGISTRY_IMAGE}:latest" .
- docker push "${REGISTRY_IMAGE}:${CI_COMMIT_TAG}"
- docker push "${REGISTRY_IMAGE}:latest"
only:
variables:
- $CI_COMMIT_TAG =~ /^[0-9.]+$/
retry: 2
notify_succcess_slack:
stage: notifications
allow_failure: true
script:
- apk --update add curl
- date=$(date +%Y%m%d-%H%M)
- './.cicd/notify_slack.sh "#builds" "$RELEASE_IMAGE - build success at $date"'
when: on_success
only:
variables:
- $CI_COMMIT_TAG =~ /^[0-9.]+$/
notify_fail_slack:
stage: notifications
allow_failure: true
script:
- apk --update add curl
- date=$(date +%Y%m%d-%H%M)
- './.cicd/notify_slack.sh "#builds" "$RELEASE_IMAGE - build failure at $date"'
when: on_failure
only:
variables:
- $CI_COMMIT_TAG =~ /^[0-9.]+$/