From 073b88d40b6224ca21a3593708b1423667f9c522 Mon Sep 17 00:00:00 2001 From: Acho Arnold Ewin Date: Tue, 17 Nov 2026 02:14:14 +0200 Subject: [PATCH] fix(ci): deploy web after API with run-number versions Run the web workflow only after integration tests and a successful API deployment. Use the API workflow run number for API image tags, binary versions, and the frontend client version. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: a0fd7292-f3aa-4919-929f-d73c2ac0f0c2 --- .github/workflows/api.yml | 11 +++++++++++ .github/workflows/web.yml | 10 ++++------ api/Dockerfile | 5 ++--- api/cloudbuild.yaml | 7 ++++--- web/nuxt.config.ts | 2 +- 5 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index 7d3a8a4ea..6c5848361 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -119,6 +119,7 @@ jobs: --region=global \ --project=httpsms-86c51 \ --sha=${{ github.sha }} \ + --substitutions=_VERSION=${{ github.run_number }} \ --format="value(metadata.build.id)") echo -e "Cloud Build: \033[34mhttps://console.cloud.google.com/cloud-build/builds/$BUILD_ID?project=httpsms-86c51\033[0m" echo "" @@ -133,3 +134,13 @@ jobs: esac sleep 30 done + + deploy-web: + name: Deploy Web + needs: deploy + permissions: + contents: read + pull-requests: write + deployments: write + uses: ./.github/workflows/web.yml + secrets: inherit diff --git a/.github/workflows/web.yml b/.github/workflows/web.yml index 50813d153..7ce643d66 100644 --- a/.github/workflows/web.yml +++ b/.github/workflows/web.yml @@ -1,9 +1,7 @@ name: web on: - push: - branches: - - main + workflow_call: pull_request: branches: - main @@ -46,7 +44,7 @@ jobs: run: pnpm test - name: Build 🏗️ - run: mv .env.production .env && echo "GITHUB_SHA=${GITHUB_SHA}" >> .env && pnpm run generate + run: mv .env.production .env && pnpm run generate deploy: name: Deploy @@ -61,7 +59,7 @@ jobs: - name: Setup Node 🟢 uses: actions/setup-node@v7 with: - node-version: '24.18' + node-version: "24.18" - uses: pnpm/action-setup@v6 name: Install pnpm @@ -72,7 +70,7 @@ jobs: run: pnpm install --trust-lockfile - name: Build 🏗️ - run: mv .env.production .env && echo "GITHUB_SHA=${GITHUB_SHA}" >> .env && pnpm run generate + run: mv .env.production .env && pnpm run generate - name: Cloudflare Deploy 🚀 uses: cloudflare/wrangler-action@v4 diff --git a/api/Dockerfile b/api/Dockerfile index 6e6423b1d..bd2f91ab3 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -1,7 +1,6 @@ FROM golang AS builder -ARG GIT_COMMIT -ENV GIT_COMMIT=$GIT_COMMIT +ARG VERSION WORKDIR /http-sms @@ -17,7 +16,7 @@ RUN go get github.com/swaggo/swag/cmd/swag@latest RUN go install github.com/swaggo/swag/cmd/swag RUN swag init --requiredByDefault --parseDependency --parseInternal -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=$GIT_COMMIT" -o /bin/http-sms . +RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "-X main.Version=$VERSION" -o /bin/http-sms . FROM alpine:latest diff --git a/api/cloudbuild.yaml b/api/cloudbuild.yaml index 3abc9e5d3..ce819104e 100644 --- a/api/cloudbuild.yaml +++ b/api/cloudbuild.yaml @@ -3,11 +3,11 @@ steps: id: "Build image and push" dir: "api" args: - - "--destination=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:$SHORT_SHA" + - "--destination=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:$_VERSION" - "--destination=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:latest" - "--dockerfile=Dockerfile" - "--context=." - - "--build-arg=GIT_COMMIT=$SHORT_SHA" + - "--build-arg=VERSION=$_VERSION" - "--snapshot-mode=time" - id: "Deploy to cloud run" @@ -17,7 +17,7 @@ steps: - "-c" - | gcloud run deploy $_SERVICE_NAME \ - --image=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:$SHORT_SHA \ + --image=us.gcr.io/$PROJECT_ID/$_SERVICE_NAME:$_VERSION \ --region=$_REGION --platform managed --allow-unauthenticated \ --port=8000 options: @@ -26,3 +26,4 @@ options: substitutions: _SERVICE_NAME: http-sms-api _REGION: us-east1 + _VERSION: dev diff --git a/web/nuxt.config.ts b/web/nuxt.config.ts index 87bcc2ace..ae3c47149 100644 --- a/web/nuxt.config.ts +++ b/web/nuxt.config.ts @@ -113,7 +113,7 @@ export default defineNuxtConfig({ runtimeConfig: { public: { apiBaseUrl: process.env.API_BASE_URL || 'http://localhost:8000', - clientVersion: process.env.GITHUB_SHA || 'dev', + clientVersion: process.env.GITHUB_RUN_NUMBER || 'dev', appUrl: process.env.APP_URL || 'https://httpsms.com', appName: process.env.APP_NAME || 'HTTP SMS', appGithubUrl: