This commit is contained in:
Mylloon 2021-07-27 23:20:53 +02:00
parent 64531da5b0
commit dfbb252d5c

View file

@ -1,20 +1,44 @@
image: docker:latest
stages:
- build
- test
- deploy
- push
services:
- docker:stable-dind
before_script:
- echo -n $CI_JOB_TOKEN | docker login -u gitlab-ci-token --password-stdin $CI_REGISTRY
docker-build:
image: docker:stable
Build:
stage: build
script:
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- 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
- docker pull registry.gitlab.com/confreriedukassoulait/twitchbot:latest || true
- docker build --cache-from registry.gitlab.com/confreriedukassoulait/twitchbot:latest -t twitchbot .
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
- docker tag twitchbot:latest registry.gitlab.com/confreriedukassoulait/twitchbot:latest
- docker push registry.gitlab.com/confreriedukassoulait/twitchbot:latest
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