[CI] Try to create staging namespace
This commit is contained in:
parent
22378cf133
commit
16117618e1
2 changed files with 81 additions and 43 deletions
120
.drone.yml
120
.drone.yml
|
@ -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
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
apiVersion: v1
|
||||
kind: Namespace
|
||||
metadata:
|
||||
name: beer
|
||||
name: ${NAMESPACE}
|
||||
labels:
|
||||
name: beer
|
||||
name: ${NAMESPACE}
|
||||
|
|
Loading…
Reference in a new issue