Tom/.gitlab-ci.yml

45 lines
1 KiB
YAML
Raw Normal View History

2021-07-27 23:20:53 +02:00
image: docker:latest
2021-07-27 22:51:52 +02:00
stages:
- build
2021-07-27 23:20:53 +02:00
- push
2021-07-27 22:51:52 +02:00
2021-07-27 23:20:53 +02:00
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
2021-07-27 22:51:52 +02:00
2021-07-27 23:20:53 +02:00
Build:
2021-07-27 22:41:23 +02:00
stage: build
2021-07-27 22:24:30 +02:00
script:
2021-07-27 23:20:53 +02:00
- docker pull $CI_REGISTRY_IMAGE:latest || true
- >
docker build
--pull
--build-arg VCS_REF=$CI_COMMIT_SHA
--build-arg VCS_URL=$CI_PROJECT_URL
--cache-from $CI_REGISTRY_IMAGE:latest
--tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
.
- docker push $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
2021-07-27 22:59:04 +02:00
2021-07-27 23:20:53 +02:00
Push latest:
variables:
GIT_STRATEGY: none
stage: push
only:
- main
script:
- docker pull $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA
- docker tag $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA $CI_REGISTRY_IMAGE:latest
- docker push $CI_REGISTRY_IMAGE:latest
2021-07-27 22:59:04 +02:00
2021-07-27 23:20:53 +02:00
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