Move build job to a common template

This commit is contained in:
Romain Thouvenin 2024-04-02 11:42:54 +02:00
parent 08b5af7511
commit f759581157
1 changed files with 2 additions and 35 deletions

View File

@ -7,6 +7,8 @@ stages:
include:
- template: Security/SAST.gitlab-ci.yml
- template: Security/Secret-Detection.gitlab-ci.yml
- project: mobicoop/v3/gitlab-templates
file: /ci/release.build-job.yml
##############
# TEST STAGE #
@ -28,38 +30,3 @@ test:
rules:
- if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
when: always
###############
# BUILD STAGE #
###############
build:
stage: build
image: docker:20.10.22
variables:
DOCKER_TLS_CERTDIR: ''
services:
- docker:dind
rules:
- if: $CI_COMMIT_TAG
variables:
VERSION: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH =~ /^release/ || $CI_PIPELINE_SOURCE == "web"
variables:
VERSION: $CI_COMMIT_BRANCH
before_script:
- echo -n $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
script:
- docker pull $CI_REGISTRY_IMAGE:latest || true
- >
docker build
--pull
--cache-from $CI_REGISTRY_IMAGE:latest
--tag $CI_REGISTRY_IMAGE:$VERSION
.
- docker push $CI_REGISTRY_IMAGE:$VERSION
- >
if [ $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH ]; then
docker tag $CI_REGISTRY_IMAGE:$VERSION $CI_REGISTRY_IMAGE:latest
docker push $CI_REGISTRY_IMAGE:latest
fi