From 708bf2c43e90a18546dc1e8de558113020a4c700 Mon Sep 17 00:00:00 2001 From: liberty-rising Date: Sat, 6 Jan 2024 00:43:29 +0100 Subject: [PATCH] generate unique sha for each image --- .github/workflows/build-and-deploy.yaml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-deploy.yaml b/.github/workflows/build-and-deploy.yaml index 1f15d3b..7281384 100644 --- a/.github/workflows/build-and-deploy.yaml +++ b/.github/workflows/build-and-deploy.yaml @@ -15,25 +15,25 @@ jobs: - name: Build and Push Frontend Docker Image run: | - docker build --build-arg VITE_API_URL=${{ secrets.VITE_API_URL }} -t registry.digitalocean.com/docshow-ai/frontend-prod:latest -f frontend/Dockerfile.prod frontend/ + docker build --build-arg VITE_API_URL=${{ secrets.VITE_API_URL }} -t registry.digitalocean.com/docshow-ai/frontend-prod:${{ github.sha }} -f frontend/Dockerfile.prod frontend/ echo ${{ secrets.REGISTRY_PASSWORD }} | docker login registry.digitalocean.com -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin - docker push registry.digitalocean.com/docshow-ai/frontend-prod:latest + docker push registry.digitalocean.com/docshow-ai/frontend-prod:${{ github.sha }} - name: Build and Push Backend Docker Image run: | - docker build -t registry.digitalocean.com/docshow-ai/backend-prod:latest -f backend/Dockerfile.prod backend/ + docker build -t registry.digitalocean.com/docshow-ai/backend-prod:${{ github.sha }} -f backend/Dockerfile.prod backend/ echo ${{ secrets.REGISTRY_PASSWORD }} | docker login registry.digitalocean.com -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin - docker push registry.digitalocean.com/docshow-ai/backend-prod:latest + docker push registry.digitalocean.com/docshow-ai/backend-prod:${{ github.sha }} - name: Build and Push Migration Docker Image run: | - docker build -t registry.digitalocean.com/docshow-ai/migration-prod:latest -f backend/Dockerfile.migration backend/ + docker build -t registry.digitalocean.com/docshow-ai/migration-prod:${{ github.sha }} -f backend/Dockerfile.migration backend/ echo ${{ secrets.REGISTRY_PASSWORD }} | docker login registry.digitalocean.com -u ${{ secrets.REGISTRY_USERNAME }} --password-stdin - docker push registry.digitalocean.com/docshow-ai/migration-prod:latest + docker push registry.digitalocean.com/docshow-ai/migration-prod:${{ github.sha }} - name: Set up Kubectl and Update Deployment run: | echo "${{ secrets.KUBECONFIG_SECRET }}" | base64 --decode > kubeconfig.yml - kubectl --kubeconfig=kubeconfig.yml set image deployment/frontend-deployment frontend=registry.digitalocean.com/docshow-ai/frontend-prod:latest - kubectl --kubeconfig=kubeconfig.yml set image deployment/backend-deployment backend=registry.digitalocean.com/docshow-ai/backend-prod:latest + kubectl --kubeconfig=kubeconfig.yml set image deployment/frontend-deployment frontend=registry.digitalocean.com/docshow-ai/frontend-prod:${{ github.sha }} + kubectl --kubeconfig=kubeconfig.yml set image deployment/backend-deployment backend=registry.digitalocean.com/docshow-ai/backend-prod:${{ github.sha }} kubectl --kubeconfig=kubeconfig.yml apply -f k8s/migration-job.yaml