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