54 lines
1.2 KiB
YAML
54 lines
1.2 KiB
YAML
stages:
|
|
- build
|
|
- deploy
|
|
|
|
variables:
|
|
PY_COLORS: '1'
|
|
ANSIBLE_FORCE_COLOR: '1'
|
|
ANSIBLE_PYTHON_INTERPRETER: auto_silent
|
|
ANSIBLE_STDOUT_CALLBACK: debug
|
|
|
|
docker-build-main:
|
|
# Official docker image.
|
|
image: docker:latest
|
|
stage: build
|
|
tags:
|
|
- docker
|
|
services:
|
|
- docker:dind
|
|
before_script:
|
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
script:
|
|
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
|
|
- docker push "$CI_REGISTRY_IMAGE"
|
|
only:
|
|
- main
|
|
|
|
docker-build:
|
|
# Official docker image.
|
|
image: docker:latest
|
|
stage: build
|
|
tags:
|
|
- docker
|
|
services:
|
|
- docker:dind
|
|
before_script:
|
|
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
|
script:
|
|
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
|
|
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
|
|
except:
|
|
- main
|
|
|
|
deploy-main:
|
|
#when: manual
|
|
stage: deploy
|
|
image:
|
|
name: cytopia/ansible:latest-tools
|
|
entrypoint: [""]
|
|
script:
|
|
- chmod 600 "${ANSIBLE_SSH_KEY_PRIVATE}"
|
|
- ansible-playbook -i ./deployment/hosts.yml --private-key "${ANSIBLE_SSH_KEY_PRIVATE}" "./deployment/deployment.yml"
|
|
only:
|
|
- main
|