beer/.drone.yml
kleph 22378cf133
All checks were successful
continuous-integration/drone/push Build is passing
[CI] Tag docker image to deploy it
2020-02-25 01:52:44 +01:00

86 lines
1.6 KiB
YAML

---
kind: pipeline
name: lint
steps:
- name: yaml lint
image: cytopia/yamllint
commands:
- yamllint .
- name: docker lint
image: hadolint/hadolint
commands:
- hadolint Dockerfile # ignore pinning version in pip
- name: w3c validator
image: validator/validator:latest
commands:
- vnu static/*.html
- name: markdown lint
image: pipelinecomponents/markdownlint:latest
commands:
- mdl --style all --warnings .
---
kind: pipeline
name: unit tests
steps:
- name: unit test
image: python:slim
commands:
- pip install -r requirements.txt
- pip install pylint
- pylint beer/*.py tests/*.py
- python -m pytest tests
depends_on:
- lint
---
kind: pipeline
name: build
steps:
- name: build image
image: plugins/docker
settings:
repo: kleph/beer
tags: ${DRONE_COMMIT_SHA:0:8}
username:
from_secret: dockerhub_username
password:
from_secret: dockerhub_password
depends_on:
- unit tests
---
kind: pipeline
name: deploy
steps:
- name: deploy
image: sinlead/drone-kubectl
settings:
kubernetes_server:
from_secret: kubectl_uri
kubernetes_cert:
from_secret: kubectl_cert
kubernetes_token:
from_secret: kubectl_token
environment:
IMAGE_TAG: ${DRONE_COMMIT_SHA:0:8}
commands:
- echo "== pre deploy status:"
- kubectl get pods --namespace=beer
- kubectl get deployments --namespace=beer
- kubectl get svc --namespace=beer
- cat kube/beer-deployment.yaml > kube/beer-deployment-${IMAGE_TAG}.yaml
- kubectl apply -f kube/beer-deployment-${IMAGE_TAG}.yaml --namespace=beer
- echo "== post deploy status:"
depends_on:
- build