diff --git a/.drone.yml b/.drone.yml index 1bbe67c..e89f9ab 100644 --- a/.drone.yml +++ b/.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 diff --git a/kube/beer-namespace.yaml b/kube/beer-namespace.yaml index 119770a..899e8fa 100644 --- a/kube/beer-namespace.yaml +++ b/kube/beer-namespace.yaml @@ -2,6 +2,6 @@ apiVersion: v1 kind: Namespace metadata: - name: beer + name: ${NAMESPACE} labels: - name: beer + name: ${NAMESPACE}