From 337c2ded6588528f380c33496ecad8ce67ac6dab Mon Sep 17 00:00:00 2001 From: PedroQuessada Date: Thu, 14 Mar 2024 17:50:19 -0300 Subject: [PATCH] change image name --- .github/workflows/deploy-app.yml | 10 ++++++---- k8s/api-deployment.yaml | 2 +- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/deploy-app.yml b/.github/workflows/deploy-app.yml index 8a3403b..533f0d3 100644 --- a/.github/workflows/deploy-app.yml +++ b/.github/workflows/deploy-app.yml @@ -11,7 +11,8 @@ jobs: DB_USERNAME: ${{ vars.DB_USERNAME}} DB_PASSWORD: ${{ secrets.DB_PASSWORD }} DB_NAME: "postgres" - IMAGE_NAME: ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.prefix }}-${{ vars.PROJECT_ID }}/app:${{ github.run_id }} + IMAGE_NAME: ${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.prefix }}-${{ vars.PROJECT_ID }}/app + IMAGE_TAG: ${{ github.run_id }} steps: - name: Checkout Repo @@ -32,8 +33,8 @@ jobs: env: GOOGLE_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }} run: | - docker build -t "$IMAGE_NAME" . - docker push "$IMAGE_NAME" + docker build -t "$IMAGE_NAME:$IMAGE_TAG" . + docker push "$IMAGE_NAME:$IMAGE_TAG" - name: Configure Kubernetes run: gcloud container clusters get-credentials ${{ vars.prefix }}-${{ vars.PROJECT_ID }}-gke --region ${{ vars.ZONE }} --project ${{ vars.PROJECT_ID }} @@ -47,7 +48,8 @@ jobs: - name: Deploy deployment to GKE working-directory: k8s/ run: | - export IMAGE_NAME=${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.prefix }}-${{ vars.PROJECT_ID }}/app:${{ github.run_id }} + export IMAGE_NAME=${{ vars.REGION }}-docker.pkg.dev/${{ vars.PROJECT_ID }}/${{ vars.prefix }}-${{ vars.PROJECT_ID }}/app + export IMAGE_TAG=${{ github.run_id }} kubectl apply -f api-configmap.yaml kubectl apply -f api-deployment.yaml kubectl apply -f api-service.yaml diff --git a/k8s/api-deployment.yaml b/k8s/api-deployment.yaml index 17a7e40..7e9633b 100644 --- a/k8s/api-deployment.yaml +++ b/k8s/api-deployment.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: api-container - image: ${IMAGE_NAME} + image: ${IMAGE_NAME}:${IMAGE_TAG} workingDir: /usr/api resources: requests: