This repository has been archived on 2022-06-13. You can view files and clone it, but cannot push or open issues or pull requests.
KassouBot/.gitlab-ci.yml

66 lines
1.7 KiB
YAML
Raw Normal View History

2021-07-28 01:08:51 +02:00
###############################################################
# Setting I use for cleaning up image tags #
2021-07-29 01:11:59 +02:00
# - Running cleanup every week #
# - Keeping 1 tag per image name matching : (?:v.\d+|dev) #
2021-07-28 01:08:51 +02:00
# - Removing tags older than 7 days matching the default : .* #
###############################################################
image: docker:stable
stages:
- build
- push
services:
- docker:dind
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
Build:
stage: build
script:
2021-08-16 20:21:39 +02:00
- docker pull $CI_REGISTRY_IMAGE:dev || true
2021-07-28 01:08:51 +02:00
- >
docker build
--pull
--build-arg VCS_REF=$CI_COMMIT_SHA
--build-arg VCS_URL=$CI_PROJECT_URL
2021-08-16 20:21:39 +02:00
--cache-from $CI_REGISTRY_IMAGE:dev
2021-07-28 01:08:51 +02:00
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
.
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
2021-08-16 20:21:39 +02:00
Push latest:
2021-07-28 01:08:51 +02:00
variables:
GIT_STRATEGY: none
stage: push
only:
2021-08-16 20:21:39 +02:00
- main
2021-07-28 01:08:51 +02:00
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
2021-08-16 20:21:39 +02:00
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
Push dev:
variables:
GIT_STRATEGY: none
stage: push
only:
- dev
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:dev
- docker push $CI_REGISTRY_IMAGE:dev
Push tag:
variables:
GIT_STRATEGY: none
stage: push
only:
- tags
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME