From 90f8de11aa8528db732570f68ef59d9e58cfe81f Mon Sep 17 00:00:00 2001 From: Shirou-kun Date: Tue, 12 Nov 2024 01:57:16 +0900 Subject: [PATCH] fix: image check + deploy empty full tag bug --- .github/workflows/build-push-gcloud.yaml | 6 +----- .github/workflows/cd-build.yaml | 11 ++++++----- .../infra/init-network-k8s/Pulumi.prod.yaml | 8 ++++++++ iac/pulumi-gcp/infra/k8s-cluster/Pulumi.prod.yaml | 8 ++++++++ .../infra/whisper-notes-db/Pulumi.prod.yaml | 7 +++++++ iac/services/backend/kustomization.yaml | 5 ++--- iac/services/frontend/kustomization.yaml | 6 +++--- 7 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 iac/pulumi-gcp/infra/init-network-k8s/Pulumi.prod.yaml create mode 100644 iac/pulumi-gcp/infra/k8s-cluster/Pulumi.prod.yaml create mode 100644 iac/pulumi-gcp/infra/whisper-notes-db/Pulumi.prod.yaml diff --git a/.github/workflows/build-push-gcloud.yaml b/.github/workflows/build-push-gcloud.yaml index 734dcee5..46504da7 100644 --- a/.github/workflows/build-push-gcloud.yaml +++ b/.github/workflows/build-push-gcloud.yaml @@ -34,9 +34,6 @@ on: tag: description: "Image tag" value: ${{ jobs.push.outputs.tag }} - full_tag: - description: "Full image tag" - value: ${{ jobs.push.outputs.full_tag }} jobs: push: name: "Build & Push" @@ -44,7 +41,6 @@ jobs: outputs: imageid: ${{ steps.build.outputs.imageid }} tag: ${{ steps.vars.outputs.tag }} - full_tag: ${{ steps.vars.outputs.full_tag }} steps: - uses: actions/checkout@v4 - name: Docker login to Google Cloud @@ -69,7 +65,7 @@ jobs: with: registry: ${{ inputs.registry }} image_name: ${{ secrets.GCLOUD_PROJECT }}/${{ inputs.repo }} - tag: ${{ steps.vars.outputs.branch }}-${{ steps.vars.outputs.sha_short }} + tag: ${{ steps.vars.outputs.tag }} - uses: docker/setup-buildx-action@v3 if: steps.image_exists.outcome == 'failure' - uses: docker/build-push-action@v5 diff --git a/.github/workflows/cd-build.yaml b/.github/workflows/cd-build.yaml index 6b5b58b4..f8171f0e 100644 --- a/.github/workflows/cd-build.yaml +++ b/.github/workflows/cd-build.yaml @@ -39,15 +39,16 @@ jobs: run: | # Write the new image tags to the kustomization files cd backend - kustomize edit set image grpc-backend=$BACKEND_IMAGE + kustomize edit set image grpc-backend=$REGISTRY/$GCP_PROJECT/services/whisper-notes-backend:$IMAGE_TAG cd ../frontend - kustomize edit set image frontend=$FRONTEND_IMAGE + kustomize edit set image frontend=$REGISTRY/$GCP_PROJECT/services/whisper-notes-frontend:$IMAGE_TAG # Commit the changes git add -u sha_short=$(git rev-parse --short HEAD) - git commit -m "cd: Update image to main-$sha_short" + git commit -m "cd: Update image to $sha_short" git push env: - BACKEND_IMAGE: ${{ needs.push-backend.outputs.full_tag }} - FRONTEND_IMAGE: ${{ needs.push-frontend.outputs.full_tag }} + REGISTRY: europe-north1-docker.pkg.dev + GCP_PROJECT: ${{ secrets.GCLOUD_PROJECT }} + IMAGE_TAG: ${{ needs.push-backend.outputs.tag }} diff --git a/iac/pulumi-gcp/infra/init-network-k8s/Pulumi.prod.yaml b/iac/pulumi-gcp/infra/init-network-k8s/Pulumi.prod.yaml new file mode 100644 index 00000000..3544399a --- /dev/null +++ b/iac/pulumi-gcp/infra/init-network-k8s/Pulumi.prod.yaml @@ -0,0 +1,8 @@ +encryptionsalt: v1:rJqNqFtNo3k=:v1:/pH6ZHVlVq+pb4bN:PA5f3qC95QU8lOwGB4YkVykohoDIWg== +config: + gcp:project: "" # CHANGEME: GCP Project ID + project: whisper + env: "prod" + region: "" # CHANGEME: GCP Region + shortRegion: "" # CHANGEME: GCP Short Region + ipPrefix: "172.16" diff --git a/iac/pulumi-gcp/infra/k8s-cluster/Pulumi.prod.yaml b/iac/pulumi-gcp/infra/k8s-cluster/Pulumi.prod.yaml new file mode 100644 index 00000000..3544399a --- /dev/null +++ b/iac/pulumi-gcp/infra/k8s-cluster/Pulumi.prod.yaml @@ -0,0 +1,8 @@ +encryptionsalt: v1:rJqNqFtNo3k=:v1:/pH6ZHVlVq+pb4bN:PA5f3qC95QU8lOwGB4YkVykohoDIWg== +config: + gcp:project: "" # CHANGEME: GCP Project ID + project: whisper + env: "prod" + region: "" # CHANGEME: GCP Region + shortRegion: "" # CHANGEME: GCP Short Region + ipPrefix: "172.16" diff --git a/iac/pulumi-gcp/infra/whisper-notes-db/Pulumi.prod.yaml b/iac/pulumi-gcp/infra/whisper-notes-db/Pulumi.prod.yaml new file mode 100644 index 00000000..dd4e639e --- /dev/null +++ b/iac/pulumi-gcp/infra/whisper-notes-db/Pulumi.prod.yaml @@ -0,0 +1,7 @@ +encryptionsalt: v1:rJqNqFtNo3k=:v1:/pH6ZHVlVq+pb4bN:PA5f3qC95QU8lOwGB4YkVykohoDIWg== +config: + gcp:project: "" # CHANGEME: GCP Project ID + project: whisper + env: "prod" + region: "" # CHANGEME: GCP Region + shortRegion: "" # CHANGEME: GCP Short Region diff --git a/iac/services/backend/kustomization.yaml b/iac/services/backend/kustomization.yaml index bc648f56..9752183b 100644 --- a/iac/services/backend/kustomization.yaml +++ b/iac/services/backend/kustomization.yaml @@ -20,9 +20,8 @@ labels: - pairs: app.kubernetes.io/version: latest - # CHANGEME: replace with GCP Artifact Registry images: - name: grpc-backend -- name: grpc-backend:latest - newName: europe-north1-docker.pkg.dev/${GCP_PROJECT}/services/whisper-notes-backend + # CHANGEME: replace with GCP Artifact Registry + newName: europe-north1-docker.pkg.dev/${PROJECT}/services/whisper-notes-backend newTag: main-5d9cf2b diff --git a/iac/services/frontend/kustomization.yaml b/iac/services/frontend/kustomization.yaml index c1876f0a..f5e0fb79 100644 --- a/iac/services/frontend/kustomization.yaml +++ b/iac/services/frontend/kustomization.yaml @@ -20,9 +20,9 @@ labels: - pairs: app.kubernetes.io/version: latest - # CHANGEME: replace with GCP Artifact Registry + images: - name: frontend -- name: frontend:latest - newName: europe-north1-docker.pkg.dev/${GCP_PROJECT}/services/whisper-notes-frontend + # CHANGEME: replace with GCP Artifact Registry + newName: europe-north1-docker.pkg.dev/${PROJECT}/services/whisper-notes-frontend newTag: main-3354b15