From 22378cf133cb6019d535dd10e89fcf377655636f Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 25 Feb 2020 01:46:56 +0100 Subject: [PATCH] [CI] Tag docker image to deploy it --- .drone.yml | 9 +++++++-- kube/beer-deployment.yaml | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.drone.yml b/.drone.yml index 6315c91..1bbe67c 100644 --- a/.drone.yml +++ b/.drone.yml @@ -48,7 +48,7 @@ steps: image: plugins/docker settings: repo: kleph/beer - tags: latest + tags: ${DRONE_COMMIT_SHA:0:8} username: from_secret: dockerhub_username password: @@ -71,11 +71,16 @@ steps: 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 - - kubectl apply -f kube/beer-deployment.yaml --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 diff --git a/kube/beer-deployment.yaml b/kube/beer-deployment.yaml index bf08ebb..83e916d 100644 --- a/kube/beer-deployment.yaml +++ b/kube/beer-deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: beer - image: kleph/beer + image: kleph/beer:${IMAGE_TAG} imagePullPolicy: Always ports: - containerPort: 5000