From 0a3eb40f10e52833eceb455fe2ef2feee8de65e7 Mon Sep 17 00:00:00 2001 From: louisheal Date: Tue, 7 Jan 2025 17:31:15 +0000 Subject: [PATCH] update cicd to redeploy backend --- .github/workflows/cicd.yaml | 14 +++++++++++--- .k8s/deployment.yaml | 2 +- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml index 9209091..1c61a34 100644 --- a/.github/workflows/cicd.yaml +++ b/.github/workflows/cicd.yaml @@ -15,7 +15,7 @@ jobs: - name: Build Docker image run: | - docker build -t ljheal/streampets-backend:latest . + docker build -t ljheal/streampets-backend:${{ github.sha }} . - name: Log in to Docker Hub uses: docker/login-action@v2 @@ -24,8 +24,12 @@ jobs: password: ${{ secrets.DOCKER_PASSWORD }} - name: Push Docker image to Docker Hub - run: | - docker push ljheal/streampets-backend:latest + uses: docker/build-push-action@v3 + with: + push: true + tags: | + ljheal/streampets-backend:latest + ljheal/streampets-backend:${{ github.sha }} deploy: needs: build @@ -50,3 +54,7 @@ jobs: kubectl apply -f .k8s/deployment.yaml kubectl apply -f .k8s/service.yaml kubectl apply -f .k8s/ingress.yaml + kubectl set image deployment/streampets-backend \ + streampets-backend-container=docker.io/ljheal/streampets-backend:${{ github.sha }} \ + -n streampets + diff --git a/.k8s/deployment.yaml b/.k8s/deployment.yaml index 64fff6e..b566085 100644 --- a/.k8s/deployment.yaml +++ b/.k8s/deployment.yaml @@ -16,7 +16,7 @@ spec: spec: containers: - name: streampets-backend-container - image: ljheal/streampets-backend:latest + image: ljheal/streampets-backend envFrom: - secretRef: name: backend-env