forked from zalando/spilo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
delivery.yaml
53 lines (45 loc) · 1.76 KB
/
delivery.yaml
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
version: "2017-09-20"
pipeline:
- id: build-spilo-cdp
env: &ENV
IMAGE: registry-write.opensource.zalan.do/acid/spilo
PGVERSION: 11
type: script
commands:
- desc: Build and push docker image
cmd: |
cd postgres-appliance
COMPRESS=false
# compress and push docker images only for commits to the master branch
if [ "x${CDP_SOURCE_BRANCH}" == "x" ] && [ "x${CDP_TARGET_BRANCH}" == "xmaster" ]; then
COMPRESS=true
PATRONIVERSION=$(sed -n 's/^ENV PATRONIVERSION=\([1-9][0-9]*\.[1-9][0-9]*\).*$/\1/p' Dockerfile)
IMAGE="$IMAGE-cdp-$PGVERSION:$PATRONIVERSION-p$CDP_TARGET_BRANCH_COUNTER"
fi
./build.sh --build-arg PGVERSION=$PGVERSION --build-arg COMPRESS=$COMPRESS -t $IMAGE .
docker images
if [ "$COMPRESS" == "true" ]; then docker push $IMAGE; fi
- id: tag-spilo
type: script
requires_human_approval: true
when:
event: push
branch: master
env:
<<: *ENV
commands:
- desc: Tag and push production spilo
cmd: |
sudo apt-get update
sudo apt-get install -y jq
PATRONIVERSION=$(sed -n 's/^ENV PATRONIVERSION=\([1-9][0-9]*\.[1-9][0-9]*\).*$/\1/p' postgres-appliance/Dockerfile)
CDP_IMAGE="$IMAGE-cdp-$PGVERSION:$PATRONIVERSION-p$CDP_TARGET_BRANCH_COUNTER"
docker pull $CDP_IMAGE
PIERONE_TAGS=$(curl -sL https://$(echo $IMAGE | sed 's|/|/v1/repositories/|')-$PGVERSION/tags)
COUNTER=$((git tag && echo "$PIERONE_TAGS" | jq -r 'keys | .[]') | sed -n "s/^$PATRONIVERSION-p//p" | sort -un | tail -n1)
TAG="$PATRONIVERSION-p$((COUNTER+1))"
PROD_IMAGE="$IMAGE-$PGVERSION:$TAG"
docker tag $CDP_IMAGE $PROD_IMAGE
docker images
docker push $PROD_IMAGE
git gh-tag -m $(echo $PROD_IMAGE | sed 's/-write//') $TAG