[CI] Try to create staging namespace

This commit is contained in:
kleph 2020-02-25 02:03:01 +01:00
parent 22378cf133
commit 16117618e1
2 changed files with 81 additions and 43 deletions

View file

@ -1,43 +1,43 @@
---
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: 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
@ -54,8 +54,42 @@ steps:
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}
NAMESPACE: beer-staging-${DRONE_COMMIT_SHA:0:4}
commands:
- echo "== create staging namespace ${NAMESPACE}"
- kubectl get svc --namespace=${NAMESPACE}
- cat kube/beer-deployment.yaml > kube/beer-namespace.yaml
- kubectl apply -f kube/beer-namespace.yaml
- echo "== deploy staging"
- cat kube/beer-deployment.yaml > kube/beer-deployment-${IMAGE_TAG}.yaml
- kubectl apply -f kube/beer-deployment-${IMAGE_TAG}.yaml --namespace=beer
depends_on:
- unit tests
- build
when:
branch:
exclude:
- master
---
kind: pipeline
@ -84,3 +118,7 @@ steps:
depends_on:
- build
when:
branch:
- master

View file

@ -2,6 +2,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: beer
name: ${NAMESPACE}
labels:
name: beer
name: ${NAMESPACE}