File tree Expand file tree Collapse file tree 4 files changed +74
-19
lines changed
Expand file tree Collapse file tree 4 files changed +74
-19
lines changed Original file line number Diff line number Diff line change 1- dist : xenial
2-
3- sudo : required
1+ os : linux
42
53language : python
64
@@ -19,19 +17,42 @@ addons:
1917 packages :
2018 - docker-ce
2119
20+ cache :
21+ directories :
22+ - $HOME/.cache/pip
23+ - $HOME/.cache/pre-commit
24+
2225branches :
2326 only :
2427 - master
2528
29+ stages :
30+ - name : lint
31+ - name : test
32+
2633env :
27- matrix :
34+ global :
35+ - LATEST_RELEASE=11-alpine
36+ - DOCKER_REPO=tecnativa/postgres-autoconf
37+ jobs :
2838 - DOCKER_TAG=9.6-alpine
2939 - DOCKER_TAG=10-alpine
3040 - DOCKER_TAG=11-alpine
31- - DOCKER_TAG=alpine
41+
42+ jobs :
43+ include :
44+ stage : lint
45+ script :
46+ - pre-commit run --all --show-diff-on-failure
3247
3348install :
3449 - pip install -r tests/ci-requirements.txt
3550
3651script :
3752 - ./tests/test.py -v
53+
54+ deploy :
55+ provider : script
56+ script : ./hooks/push
57+ on :
58+ branch : master
Original file line number Diff line number Diff line change 1- #! /usr/bin/env bash
2- set -ex
1+ #!/usr/bin/env python3
2+ from plumbum import FG , local
3+ from plumbum .cmd import date , docker
34
45# Check environment variables are present
5- test -n " $DOCKER_TAG "
6+ DOCKER_TAG = local .env ["DOCKER_TAG" ]
7+ COMMIT = local .env .get ("GIT_SHA1" , local .env .get ("TRAVIS_COMMIT" ))
8+ DATE = date ("--rfc-3339" , "ns" )
69
7- # Prepare build args
8- commit=" ${GIT_SHA1:- $TRAVIS_COMMIT } "
9-
10- # To be configured via Docker Hub UI, all labels from postgres image targeting
11- # this master branch
12- time docker image build \
13- --build-arg VCS_REF=" $commit " \
14- --build-arg BUILD_DATE=" $( date --rfc-3339 ns) " \
15- --build-arg BASE_TAG=" $DOCKER_TAG " \
16- --tag " tecnativa/postgres-autoconf:$DOCKER_TAG " \
17- .
10+ # Build image
11+ docker [
12+ "image" ,
13+ "build" ,
14+ "--build-arg" ,
15+ "VCS_REF={}" .format (COMMIT ),
16+ "--build-arg" ,
17+ "BUILD_DATE={}" .format (DATE ),
18+ "--build-arg" ,
19+ "BASE_TAG={}" .format (DOCKER_TAG ),
20+ "--tag" ,
21+ "tecnativa/postgres-autoconf:{}" .format (DOCKER_TAG ),
22+ "." ,
23+ ] & FG
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python3
2+ from plumbum import FG , local
3+ from plumbum .cmd import docker
4+
5+ REPO = local .env ["DOCKER_REPO" ]
6+ VERSION = local .env ["DOCKER_TAG" ]
7+
8+ # Log all locally available images; will help to pin images
9+ docker ["image" , "ls" , "--digests" , REPO ] & FG
10+
11+ # Login in Docker Hub
12+ docker (
13+ "login" ,
14+ "--username" ,
15+ local .env ["DOCKER_HUB_USERNAME" ],
16+ "--password" ,
17+ local .env ["DOCKER_HUB_TOKEN" ],
18+ )
19+
20+ # Push built images
21+ versioned_image = "%s:%s" % (REPO , VERSION )
22+ docker ["image" , "push" , versioned_image ] & FG
23+ if VERSION == local .env .get ("LATEST_RELEASE" ):
24+ latest_version = "alpine" if VERSION .endswith ("-alpine" ) else "latest"
25+ latest_image = "%s:%s" % (REPO , latest_version )
26+ docker ["image" , "tag" , versioned_image , latest_image ] & FG
27+ docker ["image" , "push" , latest_image ] & FG
Original file line number Diff line number Diff line change 11plumbum
2+ pre-commit
You can’t perform that action at this time.
0 commit comments