From 63fd6ea270a72ee583bd5268c4087bb27b3aafd0 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Sat, 5 Oct 2019 01:21:14 +0100 Subject: [PATCH 1/4] Skip labeling builds from tags with 'latest' --- .gitlab-ci.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3e06005..017688e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -72,11 +72,18 @@ build: extends: .docker script: - docker build . --pull=true --tag=${BUILD_TAG} - - docker tag ${BUILD_TAG} ${LATEST_TAG} - docker push ${BUILD_TAG} + +deploy:branch: + stage: deploy + extends: .docker + except: [ tags ] + script: + - docker pull ${BUILD_TAG} + - docker tag ${BUILD_TAG} ${LATEST_TAG} - docker push ${LATEST_TAG} -deploy: +deploy:tag: stage: deploy extends: .docker only: [ tags ] -- GitLab From c1504293151e14ea71a8bec7f5ece34374793596 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Thu, 10 Oct 2019 14:19:43 +0100 Subject: [PATCH 2/4] Install non-editable in Docker image Installing as an editable package breaks when the source is only temporarily mounted! --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index da7209e..4c58f21 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,4 +3,4 @@ ARG PY_VERSION=3.7 FROM python:$PY_VERSION RUN --mount=type=bind,rw,target=/src \ - pip install -e /src[badges] + pip install file:///src/#egg=pylint_reporter[badges] -- GitLab From 07e4ddc1bc4c55ae72b5e4c8f471ce57533fa776 Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Thu, 10 Oct 2019 16:59:03 +0100 Subject: [PATCH 3/4] Avoid CI builds on changes to master Master should only be updated with tagged changes, so builds should be from tags. --- .gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 017688e..a582045 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -70,6 +70,7 @@ lint:publish: build: stage: build extends: .docker + except: [ master ] script: - docker build . --pull=true --tag=${BUILD_TAG} - docker push ${BUILD_TAG} @@ -77,7 +78,7 @@ build: deploy:branch: stage: deploy extends: .docker - except: [ tags ] + except: [ tags master ] script: - docker pull ${BUILD_TAG} - docker tag ${BUILD_TAG} ${LATEST_TAG} -- GitLab From 8630a6347fe2992d05e41c76a710e67e1b216d5b Mon Sep 17 00:00:00 2001 From: Dom Sekotill Date: Thu, 10 Oct 2019 17:01:20 +0100 Subject: [PATCH 4/4] Tag Docker images built from Git tags as 'latest' This is safe as long as: * Pushed version tags are monotonic (reasonable for the foreseable future) * Version tag builds are not re-run from the web-UI --- .gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a582045..4160701 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -94,4 +94,6 @@ deploy:tag: script: - docker pull ${BUILD_TAG} - docker tag ${BUILD_TAG} ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG#v} + - docker tag ${BUILD_TAG} ${CI_REGISTRY_IMAGE}:latest - docker push ${CI_REGISTRY_IMAGE}:${CI_COMMIT_TAG#v} + - docker push ${CI_REGISTRY_IMAGE}:latest -- GitLab