From a320c8b496025f00954bb95646818afe42694ea7 Mon Sep 17 00:00:00 2001 From: Hari Date: Tue, 10 Feb 2026 00:27:13 +0530 Subject: [PATCH 1/4] build and deploy seperate --- .github/workflows/backend-ci.yml | 36 ++++++++++++++++++++ .github/workflows/backend-deploy.yml | 49 ++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+) create mode 100644 .github/workflows/backend-ci.yml create mode 100644 .github/workflows/backend-deploy.yml diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-ci.yml new file mode 100644 index 0000000..a52368c --- /dev/null +++ b/.github/workflows/backend-ci.yml @@ -0,0 +1,36 @@ +name: Backend CI + +on: + push: + paths: + - 'backend/**' + - '.github/workflows/backend-ci.yml' + pull_request: + paths: + - 'backend/**' + - '.github/workflows/backend-ci.yml' + +jobs: + build-test: + name: Build and Test Backend + runs-on: ubuntu-latest + + defaults: + run: + working-directory: ./backend + + steps: + - uses: actions/checkout@v4 + + - name: Setup Java + uses: actions/setup-java@v4 + with: + distribution: temurin + java-version: '21' + cache: maven + + - name: Run tests + run: mvn -B test + + - name: Build artifact + run: mvn -B -DskipTests package diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml new file mode 100644 index 0000000..fe15860 --- /dev/null +++ b/.github/workflows/backend-deploy.yml @@ -0,0 +1,49 @@ +name: Backend Deploy to Cloud Run + +on: + workflow_dispatch: + +env: + PROJECT_ID: job-tracker-pro-480917 + REGION: asia-south1 + REPO_NAME: my-repo + SERVICE_NAME: jobtracker-service + IMAGE_NAME: my-java-app + +jobs: + deploy: + name: Deploy Backend (main only) + runs-on: ubuntu-latest + + if: github.ref == 'refs/heads/main' + + environment: + name: production + + steps: + - uses: actions/checkout@v4 + + - name: Google Auth + uses: google-github-actions/auth@v2 + with: + credentials_json: '${{ secrets.GCP_CREDENTIALS }}' + + - name: Docker Auth + run: gcloud auth configure-docker ${{ env.REGION }}-docker.pkg.dev + + - name: Build and Push Image + run: | + TAG="${{ env.REGION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPO_NAME }}/${{ env.IMAGE_NAME }}:${{ github.sha }}" + docker build -t $TAG ./backend + docker push $TAG + echo "IMAGE_TAG=$TAG" >> $GITHUB_ENV + + - name: Update Service YAML + run: | + sed -i "s|image: .*|image: ${{ env.IMAGE_TAG }}|g" backend/service.yaml + + - name: Deploy to Cloud Run + uses: google-github-actions/deploy-cloudrun@v2 + with: + metadata: backend/service.yaml + region: ${{ env.REGION }} From e4768a26dce91ff98655fa7fd873502e9d11fecd Mon Sep 17 00:00:00 2001 From: Hari Date: Tue, 10 Feb 2026 00:34:40 +0530 Subject: [PATCH 2/4] test deploy --- .../workflows/{backend-ci.yml => backend-build.yml} | 10 ++++++---- .github/workflows/backend-deploy.yml | 3 ++- 2 files changed, 8 insertions(+), 5 deletions(-) rename .github/workflows/{backend-ci.yml => backend-build.yml} (77%) diff --git a/.github/workflows/backend-ci.yml b/.github/workflows/backend-build.yml similarity index 77% rename from .github/workflows/backend-ci.yml rename to .github/workflows/backend-build.yml index a52368c..12f43c3 100644 --- a/.github/workflows/backend-ci.yml +++ b/.github/workflows/backend-build.yml @@ -1,19 +1,21 @@ -name: Backend CI +name: Backend Build & Test on: push: + branches: ["**"] paths: - 'backend/**' - - '.github/workflows/backend-ci.yml' + - '.github/workflows/backend-build.yml' pull_request: + branches: ["**"] paths: - 'backend/**' - - '.github/workflows/backend-ci.yml' + - '.github/workflows/backend-build.yml' jobs: build-test: - name: Build and Test Backend runs-on: ubuntu-latest + name: Build and Test Backend defaults: run: diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml index fe15860..c8aab8a 100644 --- a/.github/workflows/backend-deploy.yml +++ b/.github/workflows/backend-deploy.yml @@ -12,9 +12,10 @@ env: jobs: deploy: - name: Deploy Backend (main only) + name: Deploy Backend runs-on: ubuntu-latest + # Optional guard: deploy only from main if: github.ref == 'refs/heads/main' environment: From a381bbd6e6a3ac258b81b27612c6aed072eee7a2 Mon Sep 17 00:00:00 2001 From: Hari Date: Tue, 10 Feb 2026 00:40:12 +0530 Subject: [PATCH 3/4] test deploy --- backend/scripts/simulate-email.ps1 | 1 + 1 file changed, 1 insertion(+) diff --git a/backend/scripts/simulate-email.ps1 b/backend/scripts/simulate-email.ps1 index 3c5a4ce..5389083 100644 --- a/backend/scripts/simulate-email.ps1 +++ b/backend/scripts/simulate-email.ps1 @@ -21,4 +21,5 @@ try { Write-Error $_ } + Write-Host "Check your local dashboard at http://localhost:4200/app/dashboard" \ No newline at end of file From 76074a33c05a04ae94393dc22c67e5b46fc984f6 Mon Sep 17 00:00:00 2001 From: Hari Date: Tue, 10 Feb 2026 00:45:28 +0530 Subject: [PATCH 4/4] revert --- backend/scripts/simulate-email.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/backend/scripts/simulate-email.ps1 b/backend/scripts/simulate-email.ps1 index 5389083..3c5a4ce 100644 --- a/backend/scripts/simulate-email.ps1 +++ b/backend/scripts/simulate-email.ps1 @@ -21,5 +21,4 @@ try { Write-Error $_ } - Write-Host "Check your local dashboard at http://localhost:4200/app/dashboard" \ No newline at end of file